?? bitmap.c
字號:
NormalizeRect (&dstOutput); if (!dc_IsMemDC (psdc) && !dc_IsMemDC (pddc)) GetBoundRect (&pddc->rc_output, &srcOutput, &dstOutput); else pddc->rc_output = dstOutput; ENTER_DRAWING (pddc); if (dc_IsMemDC (pddc) && !dc_IsMemDC (psdc)) ShowCursorForGDI (FALSE, &srcOutput); if (pddc->surface == psdc->surface && dy > sy) cliprect = pddc->ecrgn.tail; else cliprect = pddc->ecrgn.head; while (cliprect) { if (IntersectRect (&eff_rc, &pddc->rc_output, &cliprect->rc)) { SET_GAL_CLIPRECT (pddc, eff_rc); src.x = sx; src.y = sy; src.w = sw; src.h = sh; dst.x = dx; dst.y = dy; dst.w = sw; dst.h = sh; GAL_BlitSurface (psdc->surface, &src, pddc->surface, &dst); } if (pddc->surface == psdc->surface && dy > sy) cliprect = cliprect->prev; else cliprect = cliprect->next; } if (dc_IsMemDC (pddc) && !dc_IsMemDC (psdc)) ShowCursorForGDI (TRUE, &srcOutput); LEAVE_DRAWING (pddc); UNLOCK_GCRINFO (pddc);}void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh, HDC hddc, int dx, int dy, int dw, int dh, DWORD dwRop){ PDC psdc, pddc; PCLIPRECT cliprect; RECT srcOutput, dstOutput; GAL_Rect src, dst; RECT eff_rc; psdc = dc_HDC2PDC (hsdc); if (!(pddc = check_ecrgn (hddc))) return; if (sw <= 0 || sh <= 0) { sw = RECTW (psdc->DevRC); sh = RECTH (psdc->DevRC); } if (dw <= 0 || dh <= 0) { dw = RECTW (pddc->DevRC); dh = RECTH (pddc->DevRC); } // Transfer logical to device to screen here. sw += sx; sh += sy; coor_LP2SP(psdc, &sx, &sy); coor_LP2SP(psdc, &sw, &sh); SetRect (&srcOutput, sx, sy, sw, sh); NormalizeRect (&srcOutput); sw = RECTW (srcOutput); sh = RECTH (srcOutput); dw += dx; dh += dy; coor_LP2SP (pddc, &dx, &dy); coor_LP2SP (pddc, &dw, &dh); SetRect (&dstOutput, dx, dy, dw, dh); NormalizeRect (&dstOutput); dw = RECTW (dstOutput); dh = RECTH (dstOutput); if (!dc_IsMemDC (psdc) && !dc_IsMemDC (pddc)) GetBoundRect (&pddc->rc_output, &srcOutput, &dstOutput); else pddc->rc_output = dstOutput; ENTER_DRAWING (pddc); if (!dc_IsMemDC (psdc) && dc_IsMemDC (pddc)) ShowCursorForGDI (FALSE, &srcOutput); if (pddc->surface == psdc->surface && dy > sy) cliprect = pddc->ecrgn.tail; else cliprect = pddc->ecrgn.head; while(cliprect) { if (IntersectRect (&eff_rc, &pddc->rc_output, &cliprect->rc)) { SET_GAL_CLIPRECT (pddc, eff_rc); src.x = sx; src.y = sy; src.w = sw; src.h = sh; dst.x = dx; dst.y = dy; dst.w = dw; dst.h = dh; GAL_SoftStretch (psdc->surface, &src, pddc->surface, &dst); } if (pddc->surface == psdc->surface && dy > sy) cliprect = cliprect->prev; else cliprect = cliprect->next; } if (!dc_IsMemDC (psdc) && dc_IsMemDC (pddc)) ShowCursorForGDI (TRUE, &srcOutput); LEAVE_DRAWING (pddc); UNLOCK_GCRINFO (pddc);}/* * This function performs a fast box scaling. * This is a DDA-based algorithm; Iteration over target bitmap. * * This function comes from SVGALib, Copyright 1993 Harm Hanemaayer *//* We use the 32-bit to 64-bit multiply and 64-bit to 32-bit divide of the * 386 (which gcc doesn't know well enough) to efficiently perform integer * scaling without having to worry about overflows. */#if defined(__GNUC__) && defined(i386)static inline int muldiv64(int m1, int m2, int d){ /* int32 * int32 -> int64 / int32 -> int32 */ int result; int dummy; __asm__ __volatile__ ( "imull %%edx\n\t" "idivl %4\n\t" : "=a"(result), "=d"(dummy) /* out */ : "0"(m1), "1"(m2), "g"(d) /* in */ /***rjr***: "ax", "dx"***/ /* mod */ ); return result;}#elsestatic inline int muldiv64 (int m1, int m2, int d){ long long int mul = (long long int) m1 * m2; return (int) (mul / d);}#endifBOOL ScaleBitmap (BITMAP *dst, const BITMAP *src){ BYTE *dp1 = src->bmBits; BYTE *dp2 = dst->bmBits; int xfactor; int yfactor; if (dst->bmWidth == 0 || dst->bmHeight == 0) return TRUE; if (dst->bmBytesPerPixel != src->bmBytesPerPixel) return FALSE; xfactor = muldiv64 (src->bmWidth, 65536, dst->bmWidth); /* scaled by 65536 */ yfactor = muldiv64 (src->bmHeight, 65536, dst->bmHeight); /* scaled by 65536 */ switch (dst->bmBytesPerPixel) { case 1: { int y, sy; sy = 0; for (y = 0; y < dst->bmHeight;) { int sx = 0; BYTE *dp2old = dp2; int x; x = 0; while (x < dst->bmWidth - 8) {#if 0 // defined(__GNUC__) && defined(i386) /* This saves just a couple of cycles per */ /* pixel on a 486, but I couldn't resist. */ __asm__ __volatile__("movl %4, %%eax\n\t" "shrl $16, %%eax\n\t" "addl %5, %4\n\t" "movb (%3, %%eax), %%al\n\t" "movb %%al, (%1, %2)\n\t" "movl %4, %%eax\n\t" "shrl $16, %%eax\n\t" "addl %5, %4\n\t" "movb (%3, %%eax), %%al\n\t" "movb %%al, 1 (%1, %2)\n\t" "movl %4, %%eax\n\t" "shrl $16, %%eax\n\t" "addl %5, %4\n\t" "movb (%3, %%eax), %%al\n\t" "movb %%al, 2 (%1, %2)\n\t" "movl %4, %%eax\n\t" "shrl $16, %%eax\n\t" "addl %5, %4\n\t" "movb (%3, %%eax), %%al\n\t" "movb %%al, 3 (%1, %2)\n\t" "movl %4, %%eax\n\t" "shrl $16, %%eax\n\t" "addl %5, %4\n\t" "movb (%3, %%eax), %%al\n\t" "movb %%al, 4 (%1, %2)\n\t" "movl %4, %%eax\n\t" "shrl $16, %%eax\n\t" "addl %5, %4\n\t" "movb (%3, %%eax), %%al\n\t" "movb %%al, 5 (%1, %2)\n\t" "movl %4, %%eax\n\t" "shrl $16, %%eax\n\t" "addl %5, %4\n\t" "movb (%3, %%eax), %%al\n\t" "movb %%al, 6 (%1, %2)\n\t" "movl %4, %%eax\n\t" "shrl $16, %%eax\n\t" "addl %5, %4\n\t" "movb (%3, %%eax), %%al\n\t" "movb %%al, 7 (%1, %2)\n\t" : /* output */ : /* input */ "ax"(0), "r"(dp2), "r"(x), "r"(dp1), "r"(sx), "r"(xfactor) :"ax", "4" );#else *(dp2 + x) = *(dp1 + (sx >> 16)); sx += xfactor; *(dp2 + x + 1) = *(dp1 + (sx >> 16)); sx += xfactor; *(dp2 + x + 2) = *(dp1 + (sx >> 16)); sx += xfactor; *(dp2 + x + 3) = *(dp1 + (sx >> 16)); sx += xfactor; *(dp2 + x + 4) = *(dp1 + (sx >> 16)); sx += xfactor; *(dp2 + x + 5) = *(dp1 + (sx >> 16)); sx += xfactor; *(dp2 + x + 6) = *(dp1 + (sx >> 16)); sx += xfactor; *(dp2 + x + 7) = *(dp1 + (sx >> 16)); sx += xfactor;#endif x += 8; } while (x < dst->bmWidth) { *(dp2 + x) = *(dp1 + (sx >> 16)); sx += xfactor; x++; } dp2 += dst->bmPitch; y++; while (y < dst->bmHeight) { int l; int syint = sy >> 16; sy += yfactor; if ((sy >> 16) != syint) break; /* Copy identical lines. */ l = dp2 - dp2old; memcpy(dp2, dp2old, l); dp2old = dp2; dp2 += l; y++; } dp1 = src->bmBits + (sy >> 16) * src->bmPitch; } } break; case 2: { int y, sy; sy = 0; for (y = 0; y < dst->bmHeight;) { int sx = 0; BYTE *dp2old = dp2; int x; x = 0; /* This can be greatly optimized with loop */ /* unrolling; omitted to save space. */ while (x < dst->bmWidth) { *(unsigned short *) (dp2 + x * 2) = *(unsigned short *) (dp1 + (sx >> 16) * 2); sx += xfactor; x++; } dp2 += dst->bmPitch; y++; while (y < dst->bmHeight) { int l; int syint = sy >> 16; sy += yfactor; if ((sy >> 16) != syint) break; /* Copy identical lines. */ l = dp2 - dp2old; memcpy(dp2, dp2old, l); dp2old = dp2; dp2 += l; y++; } dp1 = src->bmBits + (sy >> 16) * src->bmPitch; } } break; case 3: { int y, sy; sy = 0; for (y = 0; y < dst->bmHeight;) { int sx = 0; BYTE *dp2old = dp2; int x; x = 0; /* This can be greatly optimized with loop */ /* unrolling; omitted to save space. */ while (x < dst->bmWidth) { *(unsigned short *) (dp2 + x * 3) = *(unsigned short *) (dp1 + (sx >> 16) * 3); *(unsigned char *) (dp2 + x * 3 + 2) = *(unsigned char *) (dp1 + (sx >> 16) * 3 + 2); sx += xfactor; x++; } dp2 += dst->bmPitch; y++; while (y < dst->bmHeight) { int l; int syint = sy >> 16; sy += yfactor; if ((sy >> 16) != syint) break; /* Copy identical lines. */ l = dp2 - dp2old; memcpy(dp2, dp2old, l); dp2old = dp2; dp2 += l; y++; } dp1 = src->bmBits + (sy >> 16) * src->bmPitch; } } break; case 4: { int y, sy; sy = 0; for (y = 0; y < dst->bmHeight;) { int sx = 0; BYTE *dp2old = dp2;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -