int FillRect_16bpp(HDC hdc, HRECT rect, HBRUSH hbr) { int x, y; uint16 *dstp; int nXDest, nYDest; int nWidth, nHeight; uint16 color16; RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight); if (ClipCoords(hdc, &nXDest, &nYDest, &nWidth, &nHeight, NULL, NULL) == 0) return 0; color16 = gdi_get_color_16bpp(hdc, hbr->color); for (y = 0; y < nHeight; y++) { dstp = (uint16*) gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y); if (dstp != 0) { for (x = 0; x < nWidth; x++) { *dstp = color16; dstp++; } } } InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight); return 0; }
int FillRect_32bpp(HDC hdc, HRECT rect, HBRUSH hbr) { int x, y; uint8 *dstp; char r, g, b; int nXDest, nYDest; int nWidth, nHeight; RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight); if (ClipCoords(hdc, &nXDest, &nYDest, &nWidth, &nHeight, NULL, NULL) == 0) return 0; GetRGB(r, g, b, hbr->color); for (y = 0; y < nHeight; y++) { dstp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y); if (dstp != 0) { for (x = 0; x < nWidth; x++) { *dstp = b; dstp++; *dstp = g; dstp++; *dstp = r; #ifdef USE_ALPHA dstp++; *dstp = 0xFF; dstp++; #else dstp += 2; #endif } } } InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight); return 0; }
int FillRect_16bpp(HDC hdc, HRECT rect, HBRUSH hbr) { int x, y; char *dstp; char r, g, b; int nXDest, nYDest; int nWidth, nHeight; uint16 *dstp16; uint16 color16; RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight); if (ClipCoords(hdc, &nXDest, &nYDest, &nWidth, &nHeight, NULL, NULL) == 0) return 0; GetRGB(r, g, b, hbr->color); RGB_888_565(r, g, b); color16 = RGB16(r, g, b); for (y = 0; y < nHeight; y++) { dstp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y); if (dstp != 0) { for (x = 0; x < nWidth; x++) { dstp16 = (uint16*) dstp; *dstp16 = color16; dstp += 2; } } } InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight); return 0; }
int ClipCoords(HDC hdc, int *x, int *y, int *w, int *h, int *srcx, int *srcy) { RECT bmp; RECT clip; RECT coords; HBITMAP hBmp; int dx = 0; int dy = 0; int draw = 1; if (hdc == NULL) return 0; hBmp = (HBITMAP) hdc->selectedObject; if (hBmp != NULL) { if (hdc->clip->null) { CRgnToRect(0, 0, hBmp->width, hBmp->height, &clip); } else { RgnToRect(hdc->clip, &clip); CRgnToRect(0, 0, hBmp->width, hBmp->height, &bmp); if (clip.left < bmp.left) clip.left = bmp.left; if (clip.right > bmp.right) clip.right = bmp.right; if (clip.top < bmp.top) clip.top = bmp.top; if (clip.bottom > bmp.bottom) clip.bottom = bmp.bottom; } } else { RgnToRect(hdc->clip, &clip); } CRgnToRect(*x, *y, *w, *h, &coords); if (coords.right >= clip.left && coords.left <= clip.right && coords.bottom >= clip.top && coords.top <= clip.bottom) { /* coordinates overlap with clipping region */ if (coords.left < clip.left) { dx = (clip.left - coords.left) + 1; coords.left = clip.left; } if (coords.right > clip.right) coords.right = clip.right; if (coords.top < clip.top) { dy = (clip.top - coords.top) + 1; coords.top = clip.top; } if (coords.bottom > clip.bottom) coords.bottom = clip.bottom; } else { /* coordinates do not overlap with clipping region */ coords.left = 0; coords.right = 0; coords.top = 0; coords.bottom = 0; draw = 0; } if (srcx != NULL) { if (dx > 0) { *srcx += dx - 1; } } if (srcy != NULL) { if (dy > 0) { *srcy += dy - 1; } } RectToCRgn(&coords, x, y, w, h); return draw; }