int icqskin_drawImage(HPS hps, PRECTL rcl, HBITMAP image, HBITMAP mask) { POINTL aptl[4]; BITMAPINFOHEADER bmpData; int x,y; GpiQueryBitmapParameters(image, &bmpData); x = ((rcl->xRight - rcl->xLeft)/2) - (bmpData.cx/2); y = ((rcl->yTop - rcl->yBottom)/2) - (bmpData.cy/2); aptl[0].x = x+rcl->xLeft; aptl[0].y = y+rcl->yBottom; aptl[1].x = (aptl[0].x+bmpData.cx)-1; aptl[1].y = (aptl[0].y+bmpData.cy)-1; aptl[2].x = aptl[2].y = 0; aptl[3].x = bmpData.cx; aptl[3].y = bmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps, mask, 4, aptl, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, image, 4, aptl, ROP_SRCPAINT, BBO_IGNORE); return bmpData.cy; }
void drawTransparent(HPS hps, PPOINTL p, XBITMAP *b) { BITMAPINFOHEADER bmpData; POINTL aptl[4]; if(!b->masc) return; bmpData.cbFix = sizeof(bmpData); GpiQueryBitmapParameters(b->masc, &bmpData); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); // Target - Inclusive aptl[0].x = p->x; aptl[0].y = p->y; aptl[1].x = p->x+bmpData.cx; aptl[1].y = p->y+bmpData.cy; // Source - Non inclusive aptl[2].x = 0; aptl[2].y = 0; aptl[3].x = bmpData.cx+1; aptl[3].y = bmpData.cy+1; GpiWCBitBlt( hps, b->masc, 4, aptl, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, b->image, 4, aptl, ROP_SRCPAINT, BBO_IGNORE); /* GpiWCBitBlt( hps, b->image, 4, aptl, ROP_SRCCOPY, BBO_IGNORE); */ }
USHORT drawIcon(HPS hps, XBITMAP *b, USHORT id, USHORT x, USHORT y) { BITMAPINFOHEADER bmpData; POINTL aptl[4]; USHORT fator; if(!b->masc) return 0; bmpData.cbFix = sizeof(bmpData); GpiQueryBitmapParameters(b->masc, &bmpData); aptl[0].x = x; aptl[0].y = y; aptl[1].x = x+bmpData.cy-1; aptl[1].y = y+bmpData.cy-1; fator = bmpData.cy * id; aptl[2].x = fator; aptl[2].y = 0; aptl[3].x = fator + bmpData.cy; aptl[3].y = bmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps, b->masc, 4, aptl, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, b->image, 4, aptl, ROP_SRCPAINT, BBO_IGNORE); return bmpData.cy; }
static void drawFrameBG(HBITMAP *img, HBITMAP *msk, USHORT id, HPS hps, int x, int y, int cx, int cy) { POINTL aptlPoints[4]; // Image coordinates aptlPoints[0].y = y; aptlPoints[1].y = y+cy; aptlPoints[0].x = x; aptlPoints[1].x = x+cx; // Source - Non inclusive aptlPoints[2].y = 0; aptlPoints[3].y = cy+1; aptlPoints[2].x = 0; aptlPoints[3].x = cx+1; GpiWCBitBlt( hps, msk[id], 4, aptlPoints, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, img[id], 4, aptlPoints, ROP_SRCPAINT, BBO_IGNORE); }
static void drawTransparent(HPS hps, HBITMAP img, HBITMAP msk, USHORT x, USHORT y, USHORT cx, USHORT cy, USHORT baseX, USHORT baseY) { POINTL aptlPoints[4]; // Image coordinates aptlPoints[0].x = x; aptlPoints[0].y = y; aptlPoints[1].x = x+cx; aptlPoints[1].y = y+cy; // Source - Non inclusive aptlPoints[2].x = baseX; aptlPoints[2].y = baseY; aptlPoints[3].x = baseX+cx+1; aptlPoints[3].y = baseY+cy+1; GpiWCBitBlt( hps, msk, 4, aptlPoints, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, img, 4, aptlPoints, ROP_SRCPAINT, BBO_IGNORE); }
USHORT icqskin_drawIcon(SKINDATA *s, HPS hps, USHORT id, USHORT x, USHORT y) { POINTL aptl[4]; USHORT fator; aptl[0].x = x; aptl[0].y = y; aptl[1].x = x+s->iconSize-1; aptl[1].y = y+s->iconSize-1; fator = s->iconSize * id; aptl[2].x = fator; aptl[2].y = 0; aptl[3].x = fator + s->iconSize; aptl[3].y = s->iconSize; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps,s->iconMasc,4,aptl,ROP_SRCAND,BBO_IGNORE); GpiWCBitBlt( hps,s->iconImage,4,aptl,ROP_SRCPAINT,BBO_IGNORE); return s->iconSize; }
void XBitmap::Draw( XGraphicDevice * dev) { if (!(settings & GO_HIDE)) { POINTL aptl[4]; aptl[0].x = p.GetX() - dev->xOffset; aptl[0].y = p.GetY() - dev->yOffset; aptl[1].x = aptl[0].x + width; aptl[1].y = aptl[0].y + height; aptl[2].x = aptl[2].y = 0; aptl[3].x = cx; aptl[3].y = cy; GpiSetBitmap(hps, 0); GpiWCBitBlt(dev->hps, hbm, 4L, (PPOINTL) aptl, mode, BBO_IGNORE); } }
HBITMAP icqskin_createBackground(HWND hwnd, HBITMAP base) { SIZEL sizl = { 0, 0 }; DEVOPENSTRUC dop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; HAB hab = WinQueryAnchorBlock(hwnd); HBITMAP btm = NO_IMAGE; HWND owner = WinQueryWindow(hwnd, QW_OWNER); HPS hps; HDC hdc; SWP swp; BITMAPINFOHEADER2 bmih; BITMAPINFOHEADER bmpData; RECTL rcl; HBITMAP img; HBITMAP msk; HBITMAP bg; POINTL aptlPoints[4]; POINTL p; int f; int sz; WinQueryWindowPos(hwnd, &swp); hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); hps = GpiCreatePS(hab, hdc, &sizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC); /* Make base images */ GpiQueryBitmapParameters(base, &bmpData); memset(&bmih,0, sizeof(BITMAPINFOHEADER2)); bmih.cbFix = sizeof(bmih); bmih.cx = bmpData.cx; bmih.cy = bmpData.cy; bmih.cPlanes = 1; bmih.cBitCount = 1; msk = GpiCreateBitmap(hps, &bmih, 0L, NULL, NULL); GpiSetBitmap(hps,msk); aptlPoints[0].x=0; aptlPoints[0].y=0; aptlPoints[1].x=aptlPoints[0].x+bmpData.cx-1; aptlPoints[1].y=aptlPoints[0].y+bmpData.cy-1; aptlPoints[2].x=0; aptlPoints[2].y=0; aptlPoints[3].x=aptlPoints[2].x+bmpData.cx; aptlPoints[3].y=aptlPoints[2].y+bmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_PINK); GpiWCBitBlt(hps,base,4,aptlPoints,ROP_NOTSRCCOPY,BBO_IGNORE); /* Create base image */ bmih.cbFix = sizeof(bmih); bmih.cx = bmpData.cx; bmih.cy = bmpData.cy; bmih.cPlanes = 1; bmih.cBitCount = 24; img = GpiCreateBitmap( hps, &bmih, 0L, NULL, NULL); GpiSetBitmap(hps,img); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps,msk,4,aptlPoints,ROP_NOTSRCCOPY,BBO_IGNORE); GpiWCBitBlt( hps,base,4,aptlPoints,ROP_SRCAND,BBO_IGNORE); /* Draw background */ memset(&bmih,0, sizeof(BITMAPINFOHEADER2)); bmih.cbFix = sizeof(bmih); bmih.cx = swp.cx; bmih.cy = swp.cy; bmih.cPlanes = 1; bmih.cBitCount = 24; btm = GpiCreateBitmap(hps,&bmih,0L,NULL,NULL); GpiSetBitmap(hps, btm); // Ask owner window to draw the background icqskin_loadPallete(hps, 0, (const ULONG *) WinSendMsg(hwnd,WMICQ_QUERYPALLETE,0,0)); rcl.xLeft = rcl.yBottom = 0; rcl.xRight = swp.cx; rcl.yTop = swp.cy; bg = icqskin_queryBackground(owner); if(!bg || bg == NO_IMAGE) { WinFillRect(hps, &rcl, ICQCLR_BACKGROUND); } else { WinMapWindowPoints(hwnd, owner, (POINTL *) &rcl, 2); p.x = p.y = 0; WinDrawBitmap(hps, bg, &rcl, &p, CLR_WHITE, CLR_BLACK, DBM_NORMAL); } GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); if(swp.cx > bmpData.cx) { sz = bmpData.cx / 3; for(f=sz;f<(swp.cx-(sz*2));f += sz) drawTransparent(hps, img, msk, f, 0, sz, bmpData.cy, sz, 0); drawTransparent(hps, img, msk, swp.cx-(sz*2), 0, sz, bmpData.cy, sz, 0); drawTransparent(hps, img, msk, 0, 0, sz, bmpData.cy, 0, 0); drawTransparent(hps, img, msk, swp.cx-sz, 0, sz, bmpData.cy, bmpData.cx-sz, 0); } else { sz = swp.cx / 2; drawTransparent(hps, img, msk, 0, 0, sz, bmpData.cy, 0, 0); drawTransparent(hps, img, msk, sz, 0, sz, bmpData.cy, bmpData.cx-sz, 0); } // Release resources GpiSetBitmap(hps, NULLHANDLE); GpiDeleteBitmap(img); GpiDeleteBitmap(msk); GpiDestroyPS(hps); DevCloseDC(hdc); return btm; }
static VOID CreateROPBitmap(HWND hWnd) { BITMAPINFOHEADER bmp; /* Bitmap Information Header */ BITMAPINFOHEADER2 bminfo2; /* Bitmap Information Header */ HBITMAP hbmConstruct; /* Bitmap Handle */ HDC hDC; /* Device Context Handle */ HPS hpsBitmap; /* Bitmap Presentation Space Handle */ LONG cFormats; /* Formats Count */ LONG lROP = 0L; /* ROP Value */ PLONG plFormats; /* Formats Array */ POINTL aptl[4]; /* Conversion Point */ RECTL rcl; /* Window Rectangle */ SIZEL sizl; /* Sizing Structure */ register INT i, n; /* Loop Counters */ if ( hbmROP ) GpiDeleteBitmap(hbmROP); GpiQueryBitmapParameters(hbmView, &bmp); /* Get bitmap device context handle for the main */ /* Client Window */ if ( !(hDC = DevOpenDC(hAB, OD_MEMORY, "*", 0L, 0L, 0L)) ) return((HBITMAP)NULL); /* Create bitmap presentation space specifying */ /* entire map Client Window for size required */ WinQueryWindowRect(hWnd, &rcl); lHorzRange = (cxROP = sizl.cx = bmp.cx * 16L + 150L) - (cxWindow = rcl.xRight - rcl.xLeft); lVertRange = (cyROP = sizl.cy = bmp.cy * 16L + 150L) - (cyWindow = rcl.yTop - rcl.yBottom); WinSendMsg(hwndVScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lVertPos), MPFROM2SHORT(0, lVertRange)); WinSendMsg(hwndVScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cyWindow, cyROP), 0L); WinSendMsg(hwndHScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lHorzPos), MPFROM2SHORT(0, lHorzRange)); WinSendMsg(hwndHScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cxWindow, cxROP), 0L); rclROP.xLeft = 0L; rclROP.yBottom = cyROP - cyWindow; rclROP.xRight = cxWindow; rclROP.yTop = cyROP; cxImage = bmp.cx + 10L; cyImage = bmp.cy + 10L; if ( !(hpsBitmap = GpiCreatePS(hAB, hDC, &sizl, PU_PELS | GPIT_NORMAL | GPIA_ASSOC)) ) { /* Error occurred during creation of */ /* presentation space, close device context */ DevCloseDC(hDC); return((HBITMAP)NULL); } /* Get the number of bitmap formats that the */ /* display driver supports */ DevQueryCaps(hDC, CAPS_BITMAP_FORMATS, 1L, &cFormats); /* Get the bitmap display formats. The first */ /* set within the array will be the one that */ /* most closely matches the display device. */ GpiQueryDeviceBitmapFormats(hpsBitmap, cFormats * 2L, plFormats = (PLONG)malloc(2UL * cFormats * sizeof(LONG))); /* Create actual bitmap storage for colour wheel */ /* having the default plane and bit count */ memset(&bminfo2, 0, sizeof(BITMAPINFOHEADER2)); bminfo2.cbFix = sizeof(BITMAPINFOHEADER2); bminfo2.cx = (ULONG)sizl.cx; bminfo2.cy = (ULONG)sizl.cy; bminfo2.cPlanes = (USHORT)plFormats[0]; bminfo2.cBitCount = (USHORT)plFormats[1]; free(plFormats); if ( !(hbmConstruct = GpiCreateBitmap(hpsBitmap, &bminfo2, 0L, 0L, 0L)) ) { /* Error occurred during creation of bitmap */ /* storage, destroy presentation space created */ /* and close device context opened */ GpiDestroyPS(hpsBitmap); DevCloseDC(hDC); return((HBITMAP)NULL); } /* Set bitmap as current bitmap to use */ GpiSetBitmap(hpsBitmap, hbmConstruct); /* Draw the page */ GpiErase(hpsBitmap); aptl[0].x = 0L; aptl[0].y = sizl.cy - bmp.cy; aptl[1].x = bmp.cx; aptl[1].y = sizl.cy; aptl[2].x = aptl[2].y = 0L; aptl[3].x = bmp.cx; aptl[3].y = bmp.cy; GpiSetPattern(hpsBitmap, lPattern); for ( i = 0; i < 16; i++ ) { for ( n = 0; n < 16; n++ ) { rcl.xLeft = aptl[0].x; rcl.xRight = aptl[1].x + 1L; rcl.yBottom = aptl[0].y; rcl.yTop = aptl[1].y + 1L; WinFillRect(hpsBitmap, &rcl, lFillColour); GpiWCBitBlt(hpsBitmap, hbmView, 4L, aptl, lROP++, BBO_IGNORE); aptl[0].x += (bmp.cx + 10L); aptl[1].x += (bmp.cx + 10L); } aptl[0].y -= (bmp.cy + 10L); aptl[1].y -= (bmp.cy + 10L); aptl[0].x = 0L; aptl[1].x = bmp.cx; } /* Set the bitmap to allow completion of bitmap */ /* in memory */ GpiSetBitmap(hpsBitmap, (HDC)NULL); /* Destroy the memory device context */ GpiAssociate(hpsBitmap, (HDC)NULL); /* Destroy the presentation spaces used */ GpiDestroyPS(hpsBitmap); DevCloseDC(hDC); /* Return the bitmap handle that will be used in */ /* painting the image on the window */ hbmROP = hbmConstruct; }
static HPOINTER combineTwoCursors(LONG idOver, LONG idUnder) { HPOINTER hptr = NULLHANDLE; POINTERINFO piOver, piUnder; HPOINTER hOver = WinQuerySysPointer(HWND_DESKTOP, idOver, FALSE); WinQueryPointerInfo(hOver, &piOver); HPOINTER hUnder = WinQuerySysPointer(HWND_DESKTOP, idUnder, FALSE); WinQueryPointerInfo(hUnder, &piUnder); if (piOver.hbmColor) { HPS hpsPtr, hpsTmp, hpsMask; HBITMAP hbmPtr, hbmTmp, hbmMask; qt_alloc_ps_with_bitmap(32, 32, false, hpsPtr, hbmPtr); qt_alloc_ps_with_bitmap(32, 32, false, hpsTmp, hbmTmp); qt_alloc_ps_with_bitmap(32, 64, true, hpsMask, hbmMask); // copy the overlying pointer POINTL ptls[] = { { 0, 0 }, { 31, 31 }, { 0, 0 }, { 32, 32 } }; GpiWCBitBlt(hpsTmp, piOver.hbmColor, 4, ptls, ROP_SRCCOPY, BBO_IGNORE); // make its transparent pixels black ptls[2].y += 32; ptls[3].y += 32; GpiSetColor(hpsTmp, CLR_TRUE); GpiSetBackColor(hpsTmp, CLR_FALSE); GpiWCBitBlt(hpsTmp, piOver.hbmPointer, 4, ptls, 0x22, BBO_IGNORE); // copy the underlying pointer ptls[2].y -= 32; ptls[3].y -= 32; GpiWCBitBlt(hpsPtr, piUnder.hbmColor, 4, ptls, ROP_SRCCOPY, BBO_IGNORE); // make non-transparent pixels from the overlying pointer black ptls[2].y += 32; ptls[3].y += 32; GpiSetColor(hpsPtr, CLR_TRUE); GpiSetBackColor(hpsPtr, CLR_FALSE); GpiWCBitBlt(hpsPtr, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE); // put the overlying pointer there ptls[2].y -= 32; ptls[3].y -= 32; ptls[1].x ++; ptls[1].y ++; GpiBitBlt(hpsPtr, hpsTmp, 4, ptls, ROP_SRCPAINT, BBO_IGNORE); // copy both underlying pointer's masks ptls[1].x --; ptls[1].y --; ptls[1].y += 32; ptls[3].y += 32; GpiWCBitBlt(hpsMask, piUnder.hbmPointer, 4, ptls, ROP_SRCCOPY, BBO_IGNORE); // add overlying pointer's XOR mask ptls[1].y -= 32; ptls[3].y -= 32; GpiWCBitBlt(hpsMask, piOver.hbmPointer, 4, ptls, ROP_SRCPAINT, BBO_IGNORE); // add overlying pointer's AND mask ptls[0].y += 32; ptls[2].y += 32; ptls[1].y += 32; ptls[3].y += 32; GpiWCBitBlt(hpsMask, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE); // create the new pointer GpiSetBitmap(hpsPtr, NULLHANDLE); GpiSetBitmap(hpsMask, NULLHANDLE); piOver.hbmColor = hbmPtr; piOver.hbmPointer = hbmMask; piOver.hbmMiniColor = NULLHANDLE; piOver.hbmMiniPointer = NULLHANDLE; hptr = WinCreatePointerIndirect(HWND_DESKTOP, &piOver); qt_free_ps_with_bitmap(hpsMask, hbmMask); qt_free_ps_with_bitmap(hpsTmp, hbmTmp); qt_free_ps_with_bitmap(hpsPtr, hbmPtr); } else { HPS hps; HBITMAP hbm; qt_alloc_ps_with_bitmap(32, 64, true, hps, hbm); POINTL ptls[] = { { 0, 0 }, { 31, 63 }, { 0, 0 }, { 32, 64 } }; // make a copy of the underlying pointer GpiWCBitBlt(hps, piUnder.hbmPointer, 4, ptls, ROP_SRCCOPY, BBO_IGNORE); // combine AND masks ptls[0].y += 32; ptls[2].y += 32; GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE); // apply the overlying AND mask to the underlying XOR mask ptls[0].y -= 32; ptls[1].y -= 32; GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE); // apply the overlying XOR mask to the underlying XOR mask ptls[2].y -= 32; ptls[3].y -= 32; GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCINVERT, BBO_IGNORE); // create the new pointer GpiSetBitmap(hps, 0); hptr = WinCreatePointer(HWND_DESKTOP, hbm, TRUE, piOver.xHotspot, piOver.yHotspot); qt_free_ps_with_bitmap(hps, hbm); } Q_ASSERT(hptr); return hptr; }
void loadTransparent( HAB hab, HDC hdc, HPS hps, XBITMAP *x, PSZ FileName) { BITMAPINFOHEADER2 bmih; HBITMAP base = LoadBitmap(hab,hdc,hps,FileName); BITMAPINFOHEADER pbmpData; /* bit-map information header */ POINTL aptlPoints[4]; // DBGMessage(FileName); if(x->masc) GpiDeleteBitmap(x->masc); if(x->image) GpiDeleteBitmap(x->image); memset(x,0,sizeof(XBITMAP)); GpiQueryBitmapParameters(base, &pbmpData); memset(&bmih,0, sizeof(BITMAPINFOHEADER2)); bmih.cbFix = sizeof(bmih); bmih.cx = pbmpData.cx; bmih.cy = pbmpData.cy; bmih.cPlanes = 1; bmih.cBitCount = 1; x->masc = GpiCreateBitmap( hps, &bmih, 0L, NULL, NULL); GpiSetBitmap(hps,x->masc); aptlPoints[0].x=0; aptlPoints[0].y=0; aptlPoints[1].x=aptlPoints[0].x+pbmpData.cx-1; aptlPoints[1].y=aptlPoints[0].y+pbmpData.cy-1; aptlPoints[2].x=0; aptlPoints[2].y=0; aptlPoints[3].x=aptlPoints[2].x+pbmpData.cx; aptlPoints[3].y=aptlPoints[2].y+pbmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_PINK); GpiWCBitBlt( hps, base, 4, aptlPoints, ROP_NOTSRCCOPY, BBO_IGNORE); bmih.cbFix = sizeof(bmih); bmih.cx = pbmpData.cx; bmih.cy = pbmpData.cy; bmih.cPlanes = 1; bmih.cBitCount = 24; x->image = GpiCreateBitmap( hps, &bmih, 0L, NULL, NULL); GpiSetBitmap(hps,x->image); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps, x->masc, 4, aptlPoints, ROP_NOTSRCCOPY, BBO_IGNORE); GpiWCBitBlt( hps, base, 4, aptlPoints, ROP_SRCAND, BBO_IGNORE); GpiSetBitmap(hps,NULLHANDLE); GpiDeleteBitmap(base); }