Changeset 31279 in vbox for trunk/src/VBox
- Timestamp:
- Aug 2, 2010 10:33:59 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64306
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/DisplayImpl.cpp
r31195 r31279 181 181 uint8_t *dst = pu8Thumbnail; 182 182 uint8_t *src = pu8Data; 183 int dstX = 0;184 int dstY = 0;185 int srcX = 0;186 int srcY = 0;187 183 int dstW = cxThumbnail; 188 184 int dstH = cyThumbnail; 189 185 int srcW = cx; 190 186 int srcH = cy; 191 gdImageCopyResampled (dst, 192 src, 193 dstX, dstY, 194 srcX, srcY, 195 dstW, dstH, srcW, srcH); 187 int iDeltaLine = cx * 4; 188 189 BitmapScale32 (dst, 190 dstW, dstH, 191 src, 192 iDeltaLine, 193 srcW, srcH); 196 194 197 195 *ppu8Thumbnail = pu8Thumbnail; … … 291 289 uint8_t *dst = pu8Bitmap; 292 290 uint8_t *src = pu8Data; 293 int dstX = 0;294 int dstY = 0;295 int srcX = 0;296 int srcY = 0;297 291 int dstW = cxBitmap; 298 292 int dstH = cyBitmap; 299 293 int srcW = cx; 300 294 int srcH = cy; 301 gdImageCopyResampled (dst, 302 src, 303 dstX, dstY, 304 srcX, srcY, 305 dstW, dstH, srcW, srcH); 295 int iDeltaLine = cx * 4; 296 297 BitmapScale32 (dst, 298 dstW, dstH, 299 src, 300 iDeltaLine, 301 srcW, srcH); 306 302 } 307 303 else … … 2469 2465 uint8_t *dst = address; 2470 2466 uint8_t *src = pu8Data; 2471 int dstX = 0;2472 int dstY = 0;2473 int srcX = 0;2474 int srcY = 0;2475 2467 int dstW = width; 2476 2468 int dstH = height; 2477 2469 int srcW = cx; 2478 2470 int srcH = cy; 2479 gdImageCopyResampled (dst, 2480 src, 2481 dstX, dstY, 2482 srcX, srcY, 2483 dstW, dstH, srcW, srcH); 2471 int iDeltaLine = cx * 4; 2472 2473 BitmapScale32 (dst, 2474 dstW, dstH, 2475 src, 2476 iDeltaLine, 2477 srcW, srcH); 2484 2478 } 2485 2479 -
trunk/src/VBox/Main/DisplayResampleImage.cpp
r28800 r31279 194 194 } 195 195 } 196 197 /* Fast interger implementation for 32 bpp bitmap scaling. 198 * Use fixed point values * 16. 199 */ 200 typedef int32_t FIXEDPOINT; 201 #define INT_TO_FIXEDPOINT(i) (FIXEDPOINT)((i) << 4) 202 #define FIXEDPOINT_TO_INT(v) (int)((v) >> 4) 203 #define FIXEDPOINT_FLOOR(v) ((v) & ~0xF) 204 #define FIXEDPOINT_FRACTION(v) ((v) & 0xF) 205 206 /* For 32 bit source only. */ 207 void BitmapScale32 (uint8_t *dst, 208 int dstW, int dstH, 209 const uint8_t *src, 210 int iDeltaLine, 211 int srcW, int srcH) 212 { 213 int x, y; 214 215 for (y = 0; y < dstH; y++) 216 { 217 FIXEDPOINT sy1 = INT_TO_FIXEDPOINT(y * srcH) / dstH; 218 FIXEDPOINT sy2 = INT_TO_FIXEDPOINT((y + 1) * srcH) / dstH; 219 220 for (x = 0; x < dstW; x++) 221 { 222 FIXEDPOINT red = 0, green = 0, blue = 0; 223 224 FIXEDPOINT sx1 = INT_TO_FIXEDPOINT(x * srcW) / dstW; 225 FIXEDPOINT sx2 = INT_TO_FIXEDPOINT((x + 1) * srcW) / dstW; 226 227 FIXEDPOINT spixels = (sx2 - sx1) * (sy2 - sy1); 228 229 FIXEDPOINT sy = sy1; 230 231 do 232 { 233 FIXEDPOINT yportion; 234 if (FIXEDPOINT_FLOOR (sy) == FIXEDPOINT_FLOOR (sy1)) 235 { 236 yportion = INT_TO_FIXEDPOINT(1) - FIXEDPOINT_FRACTION(sy); 237 if (yportion > sy2 - sy1) 238 { 239 yportion = sy2 - sy1; 240 } 241 sy = FIXEDPOINT_FLOOR (sy); 242 } 243 else if (sy == FIXEDPOINT_FLOOR (sy2)) 244 { 245 yportion = FIXEDPOINT_FRACTION(sy2); 246 } 247 else 248 { 249 yportion = INT_TO_FIXEDPOINT(1); 250 } 251 252 const uint8_t *pu8SrcLine = src + iDeltaLine * FIXEDPOINT_TO_INT(sy); 253 FIXEDPOINT sx = sx1; 254 do 255 { 256 FIXEDPOINT xportion; 257 FIXEDPOINT pcontribution; 258 int p; 259 if (FIXEDPOINT_FLOOR (sx) == FIXEDPOINT_FLOOR (sx1)) 260 { 261 xportion = INT_TO_FIXEDPOINT(1) - FIXEDPOINT_FRACTION(sx); 262 if (xportion > sx2 - sx1) 263 { 264 xportion = sx2 - sx1; 265 } 266 pcontribution = xportion * yportion; 267 sx = FIXEDPOINT_FLOOR (sx); 268 } 269 else if (sx == FIXEDPOINT_FLOOR (sx2)) 270 { 271 xportion = FIXEDPOINT_FRACTION(sx2); 272 pcontribution = xportion * yportion; 273 } 274 else 275 { 276 xportion = INT_TO_FIXEDPOINT(1); 277 pcontribution = xportion * yportion; 278 } 279 /* Color depth specific code begin */ 280 p = *(uint32_t *)(pu8SrcLine + FIXEDPOINT_TO_INT(sx) * 4); 281 /* Color depth specific code end */ 282 red += gdTrueColorGetRed (p) * pcontribution; 283 green += gdTrueColorGetGreen (p) * pcontribution; 284 blue += gdTrueColorGetBlue (p) * pcontribution; 285 286 sx += INT_TO_FIXEDPOINT(1); 287 } while (sx < sx2); 288 289 sy += INT_TO_FIXEDPOINT(1); 290 } while (sy < sy2); 291 292 if (spixels != 0) 293 { 294 red /= spixels; 295 green /= spixels; 296 blue /= spixels; 297 } 298 /* Clamping to allow for rounding errors above */ 299 if (red > 255) 300 { 301 red = 255; 302 } 303 if (green > 255) 304 { 305 green = 255; 306 } 307 if (blue > 255) 308 { 309 blue = 255; 310 } 311 gdImageSetPixel (dst, 312 x, y, 313 ( ((int) red) << 16) + (((int) green) << 8) + ((int) blue), 314 dstW); 315 } 316 } 317 } -
trunk/src/VBox/Main/include/DisplayImpl.h
r30739 r31279 273 273 274 274 275 void BitmapScale32 (uint8_t *dst, 276 int dstW, int dstH, 277 const uint8_t *src, 278 int iDeltaLine, 279 int srcW, int srcH); 280 275 281 #endif // ____H_DISPLAYIMPL 276 282 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note:
See TracChangeset
for help on using the changeset viewer.