Пример #1
0
                                        /* Initialize data for our drawing thread */
int             Draw_Initialize(void)
{
int             i;                      /* Temporary variables */

                                        /* For each symbol, open a memory devicecontext,
                                           create a presentation space and load the bitmap
                                           from the EXE file */
for(i=1;i<RB_BORDER;i++)
   {
   if(!(hdcRB[i]=DevOpenDC(hab,         /* Open device context with anchor block handle of
                                           our application */
        OD_MEMORY,                      /* Type of device context (memory) */
        (PSZ)"*",                       /* Device information token (no initialization) */
        8L,                             /* Number of items (of deviceopendata) */
        (PDEVOPENDATA)&dcRB[i],         /* Open device context data */
        (HDC)NULL)))                    /* Compatible device context (compatibilty with screen) */
        GEN_ERR(hab,hwndFrame,hwndClient);
   if(!(hpsRB[i]=GpiCreatePS(hab,       /* Create a presentation space with our anchor block
                                           handle */
        hdcRB[i],                       /* Device context handle (of our symbols) */
        &sizelRB,                       /* Presentation space size (or our symbols) */
        GPIA_ASSOC|PU_PELS)))           /* Options (assoziate to screen, pels as unit) */
        GEN_ERR(hab,hwndFrame,hwndClient);
                                        /* Load bitmap from EXE file */
   if(!(hbmRB[i]=GpiLoadBitmap(hpsRB[i],
        (HMODULE)0,                     /* Ressource (EXE file) */
        RB_RESSOURCE_ID[i],             /* ID of bitmap within ressource */
        0L,                             /* Width of bitmap in pels (no streching) */
        0L)))                           /* Height of bitmap in pels (no streching) */
        GEN_ERR(hab,hwndFrame,hwndClient);
   }
return(0);
}
static INT CreateMemoryPS (PINST pinstMain, HPS hpsTarget,
    PRECTL prclTargetWnd)
{
    SIZEL   sizl;
    HDC     hdcTarget = GpiQueryDevice(hpsTarget);

    pinstMain->hdcMem = DevOpenDC(pinstMain->hab,OD_MEMORY,"*",
        0L,NULL,hdcTarget);
    assert (pinstMain->hdcMem != DEV_ERROR);

    //
    // Set the size of the presentation space to be created.
    //
    sizl.cx = prclTargetWnd->xRight;
    sizl.cy = prclTargetWnd->yTop;

    //
    // Create the memory presentation space for the bitmap.
    //
    pinstMain->hpsMemRadar = GpiCreatePS(pinstMain->hab,
       pinstMain->hdcMem,&sizl,
       PU_PELS | GPIA_ASSOC | GPIT_MICRO);
    assert (pinstMain->hpsMemRadar != GPI_ERROR);

    return 0;
}
Пример #3
0
QT_BEGIN_NAMESPACE

HPS qt_alloc_mem_ps(int w, int h, HPS compat = 0)
{
    HDC hdcCompat = NULLHANDLE;
    if (compat)
        hdcCompat = GpiQueryDevice(compat);

    static PCSZ hdcData[4] = { "Display", NULL, NULL, NULL };
    HDC hdc = DevOpenDC(0, OD_MEMORY, "*", 4, (PDEVOPENDATA) hdcData, hdcCompat);
    if (!hdc) {
        qWarning( "alloc_mem_dc: DevOpenDC failed with %08lX!", WinGetLastError(0));
        return NULLHANDLE;
    }
    SIZEL size = { w, h };
    HPS hps = GpiCreatePS(0, hdc, &size, PU_PELS | GPIA_ASSOC | GPIT_MICRO);
    if (hps == NULLHANDLE) {
        qWarning("alloc_mem_dc: GpiCreatePS failed wit %08lX!", WinGetLastError(0));
        return NULLHANDLE;
    }
    // @todo later
//  if (QColor::hPal()) {
//      GpiSelectPalette(hps, QColor::hPal());
//  } else {
        // direct RGB mode
        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
//  }
    return hps;
}
Пример #4
0
 static int loadAlternativeIconTable(SKINDATA *wnd)
 {
    SIZEL              sizl            = { 0, 0 };  /* use same page size as device */
    DEVOPENSTRUC       dop             = { 0, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
    HAB                hab             = icqQueryAnchorBlock(wnd->icq);
    HDC                hdc;
    HPS                hps;

    CHKPoint();

    icqskin_deleteImage( wnd->iconImage );
    icqskin_deleteImage( wnd->iconMasc  );

    hdc  = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
    hps  = GpiCreatePS(hab, hdc, &sizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC);

    if(hps)
    {
       wnd->iconImage = GpiLoadBitmap(hps, module, 101, ICONBAR_ROWS * PWICQICONBARSIZE, ICONBAR_ROWS);
       wnd->iconMasc  = GpiLoadBitmap(hps, module, 102, ICONBAR_ROWS * PWICQICONBARSIZE, ICONBAR_ROWS);
       GpiDestroyPS(hps);
    }

    DevCloseDC(hdc);

    return ICONBAR_ROWS;
 }
Пример #5
0
/*@ XPrinterDevice::OpenPrinterJob(char *pszJobTitle)
@remarks Open a printer job
@parameters char * title      title of the printer job
@returns BOOL success
*/
BOOL XPrinterDevice::OpenPrinterJob(const char *pszJobTitle)
{
   hdc = DevOpenDC(pSetup->hab, pSetup->lDCType, (PSZ) "*", 9, pSetup->pDevOpenData, (HDC) 0);

   if (hdc == NULLHANDLE)
      return FALSE;

   SIZEL sizel;

   sizel.cx = 0;
   sizel.cy = 0;
   hps = GpiCreatePS(pSetup->hab, hdc, &sizel, pSetup->lWorldCoordinates | GPIF_DEFAULT | GPIT_NORMAL | GPIA_ASSOC);

   if (GPI_ERROR == hps)
   {
      DevCloseDC(hdc);
      hdc = (HDC) 0;
      hps = (HPS) 0;
      return FALSE;
   }
   DevEscape(hdc, DEVESC_STARTDOC, strlen(pszJobTitle), (PSZ) pszJobTitle, NULL, NULL);
   if (!GpiSetCharMode(hps, CM_MODE2))
      return FALSE;
   if (!GpiSetTextAlignment(hps, TA_NORMAL_HORIZ, TA_NORMAL_VERT))
      return FALSE;

   SIZEL sizPage;

   if (!GpiQueryPS(hps, &sizPage))
      return FALSE;
   width = sizPage.cx;
   height = sizPage.cy;

   return TRUE;
}
Пример #6
0
HDC os2PrintQ::OpenHDC()
{
  DEVOPENSTRUC dop;

  memset(&dop, 0, sizeof(dop));
  dop.pszDriverName = (char*)mDriverName;
  dop.pdriv         = DriverData();

  return DevOpenDC(0, OD_INFO, "*", 9, (PDEVOPENDATA)&dop, 0);
}
Пример #7
0
/*@ XBitmap :: XBitmap(const XPoint * pp1, const LONG m)
@group constructors/destructors
@remarks Construct a bitmap
@parameters   <t 'ø' c=2>
            øXPoint * p                  øleft-lower corner
            øLONG mode                  ømode, default is ROP_SRCCOPY
            </t>
@exceptions   If the method fails an exception of the type XException is thrown.
*/
XBitmap :: XBitmap(const XPoint * pp1, const LONG m):XGraphicObject(pp1)
{
   mode = m;
   owner = NULL;
   hdc = DevOpenDC(XApplication::GetApplication()->GetAnchorBlock(), OD_MEMORY, (PSZ) "*", 0, (PDEVOPENDATA) NULL, 0L);
   if (hdc == 0)
      OOLThrow("error creating device context", 4);
   hps = GpiCreatePS(XApplication::GetApplication()->GetAnchorBlock(), hdc, &g, PU_PELS | GPIA_ASSOC);
   if (hps == 0)
      OOLThrow("error creating presentation space", 5);
   width = height = cx = cy = 0;
}
Пример #8
0
gfxOS2Surface::gfxOS2Surface(const gfxIntSize& aSize,
                             gfxImageFormat aImageFormat)
    : mWnd(0), mSize(aSize)
{
#ifdef DEBUG_thebes_2
    printf("gfxOS2Surface[%#x]::gfxOS2Surface(Size=%dx%d, %d)\n", (unsigned int)this,
           aSize.width, aSize.height, aImageFormat);
#endif
    // in this case we don't have a window, so we create a memory presentation
    // space to construct the cairo surface on

    // create a PS, partly taken from nsOffscreenSurface::Init(), i.e. nsDrawingSurfaceOS2.cpp
    DEVOPENSTRUC dop = { 0, 0, 0, 0, 0 };
    SIZEL sizel = { 0, 0 }; // use same page size as device
    mDC = DevOpenDC(0, OD_MEMORY, (PSZ)"*", 5, (PDEVOPENDATA)&dop, NULLHANDLE);
    NS_ASSERTION(mDC != DEV_ERROR, "Could not create memory DC");

    mPS = GpiCreatePS(0, mDC, &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
    NS_ASSERTION(mPS != GPI_ERROR, "Could not create PS on memory DC!");

    // now create a bitmap of the right size
    BITMAPINFOHEADER2 hdr = { 0 };
    hdr.cbFix = sizeof(BITMAPINFOHEADER2);
    hdr.cx = mSize.width;
    hdr.cy = mSize.height;
    hdr.cPlanes = 1;

    // find bit depth
    LONG lBitCount = 0;
    DevQueryCaps(mDC, CAPS_COLOR_BITCOUNT, 1, &lBitCount);
    hdr.cBitCount = (USHORT)lBitCount;

    mBitmap = GpiCreateBitmap(mPS, &hdr, 0, 0, 0);
    NS_ASSERTION(mBitmap != GPI_ERROR, "Could not create bitmap in memory!");
    // set final stats & select bitmap into PS
    GpiSetBitmap(mPS, mBitmap);

    // now we can finally create the cairo surface on the in-memory PS
    cairo_surface_t *surf = cairo_os2_surface_create(mPS, mSize.width, mSize.height);
#ifdef DEBUG_thebes_2
    printf("  type(%#x)=%d (ID=%#x, h/w=%d/%d)\n", (unsigned int)surf,
           cairo_surface_get_type(surf), (unsigned int)mPS, mSize.width, mSize.height);
#endif
    // Normally, OS/2 cairo surfaces have to be forced to redraw completely
    // by calling cairo_surface_mark_dirty(surf), but Mozilla paints them in
    // full, so that is not necessary here.

    // manual refresh is done from nsWindow::OnPaint
    cairo_os2_surface_set_manual_window_refresh(surf, 1);

    Init(surf);
}
Пример #9
0
// tiles an image across preview window
BOOL DrawImage(PSPAINT * pPaint, HBITMAP hbm, short sState, PLUGINSHARE* pPluginData)
{
    SIZEL slHps;
    POINTL aptl[4];
    HDC hdc;
    HPS hps;
    HAB hab = WinQueryAnchorBlock(pPaint->hwnd);


    // setup source bitmap
    hdc = DevOpenDC(hab, OD_MEMORY, "*", 0L, (PDEVOPENDATA) NULL, NULLHANDLE);

    // create source hps
    slHps.cx = pPluginData->ulCx/2;
    slHps.cy = pPluginData->ulCy/5;
    hps = GpiCreatePS(hab,
                      hdc,
                      &slHps,
                      PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);

    // set bmp into hps
    GpiSetBitmap(hps, hbm);

    // initial blt location
    aptl[0].x = pPaint->rectlWindow.xLeft;
    //aptl[0].y = pPaint->rectlWindow.yBottom;
    aptl[0].y = pPaint->rectlWindow.yBottom-1;
    aptl[1].x = pPaint->rectlWindow.xRight;
    //aptl[1].y = pPaint->rectlWindow.yTop;
    aptl[1].y = pPaint->rectlWindow.yTop-1;
    aptl[2].x = 0;
    aptl[2].y = 0;
    aptl[3].x = slHps.cx;
    aptl[3].y = slHps.cy;
     // blt
     GpiBitBlt(pPaint->hps, hps, 4L, aptl, ROP_SRCCOPY, BBO_IGNORE);

    // clean up
    GpiSetBitmap(hps, NULLHANDLE);
    GpiDestroyPS(hps);
    DevCloseDC(hdc);

    return (TRUE);


}
Пример #10
0
void
gfxOS2Platform::InitDisplayCaps()
{
    // create DC compatible with the screen
    HDC dc = DevOpenDC((HAB)1, OD_MEMORY,"*",0L, NULL, NULLHANDLE);
    if (dc > 0) {
        // we do have a DC and we can query the DPI setting from it
        LONG lDPI;
        if (DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &lDPI))
            gfxPlatform::sDPI = lDPI;
        DevCloseDC(dc);
    }

    if (gfxPlatform::sDPI <= 0) {
        // Fall back to something sane
        gfxPlatform::sDPI = 96;
    }
}
Пример #11
0
HDC PrnOpenInfoDC(PPRN pprn, PSZ pszDataType)

{
CHAR	     achDriverName[256];   /* Driver Name			*/
DEVOPENSTRUC dop;		   /* Device Open Structure		*/
register INT i;			   /* Loop Counter			*/

if ( !pprn->cQueues )
   return((HDC)NULL);
		       /* Initialize the driver	data structure		*/

memset(&dop, 0,	sizeof(DEVOPENSTRUC));

		       /* Set the logical address			*/

dop.pszLogAddress = pprn->pquei[pprn->iQueue].pszName;

		       /* Set the driver name (ie. PSCRIPT)		*/

if ( (i	= (INT)strcspn(pprn->pquei[pprn->iQueue].pszDriverName,	".")) != 0 )
   {
   dop.pszDriverName = memcpy(achDriverName, pprn->pquei[pprn->iQueue].pszDriverName, (UINT)i);
   achDriverName[i] = (CHAR)0;
   }
else
   dop.pszDriverName = strcpy(achDriverName, pprn->pquei[pprn->iQueue].pszDriverName);

dop.pdriv  = (PVOID)pprn->pquei[pprn->iQueue].pDriverData;

		       /* Set data type	(ie. PM_Q_STD or PM_Q_RAW)	*/

dop.pszDataType	= pszDataType;

/* Other data values include:						*/
/*									*/
/*  dop.pszComment    =	"comments"; // Comment for OD_Q			*/
/*  dop.pszQueueProcName   = NULL;  // queue processor;			*/
/*				    //	NULL =>	use default		*/
/*  dop.pszQueueProcParams = NULL;  // parms for queue processor	*/
/*  dop.pszSpoolerParams   = NULL;  // spooler parms (use NULL!)	*/
/*  dop.pszNetworkParams   = NULL;  // network parms (use NULL!)	*/

return(DevOpenDC(pprn->hAB, OD_INFO, "*", 9L, (PDEVOPENDATA)(PVOID)&dop, (HDC)0L));
}
Пример #12
0
/****************************************************************\
 *
 *--------------------------------------------------------------
 *  Name:ClkCreate()
 *
 *  Purpose:Intialize a newly created client window
 *
 *  Returns:
 *	    1 - if sucessful execution completed
 *	    0 - if error
\****************************************************************/
VOID ClkCreate ( HWND hwnd )
{
    LONG cxScreen , cyScreen;  /* screen dimensions */
    LONG xLeft , yBottom ;	/* frame window location */
    ULONG cbBuf;
    LONG cyHeight;
    LONG cxWidth;

//    hwndClient = hwnd;

// extern SIZEL sizl;   clkdata.h
// SIZEL sizl = { 200 , 200 }; clkdata.c


    /* determine screen dimensions */
    /* open a device context and create a presentation space */

    hdc = WinOpenWindowDC (hwnd);
    hps = GpiCreatePS (hab, hdc, &sizl, PU_ARBITRARY | GPIT_MICRO |
	    GPIA_ASSOC);

    /*
     * Create our off-screen 'buffer'.
     */
    hdcBuffer = DevOpenDC ( (HAB)0L, OD_MEMORY, "*", 0L, NULL, hdc);
    hpsBuffer = GpiCreatePS (hab, hdcBuffer, &sizl, PU_ARBITRARY |
			       GPIT_MICRO | GPIA_ASSOC);

    GpiCreateLogColorTable (hpsBuffer, 0, LCOLF_RGB, 0, 0, (PLONG)NULL);

// ULONG cxRes , cyRes; clkdata.c
// ULONG cColorPlanes, cColorBitcount; clkdata.c


    /* get the device resolutions so we can make the face appear circular */
    DevQueryCaps (hdc, (LONG)CAPS_VERTICAL_RESOLUTION,(LONG) 1L, &cyRes);
    DevQueryCaps (hdc, CAPS_HORIZONTAL_RESOLUTION, 1L, &cxRes);
    DevQueryCaps (hdc, CAPS_COLOR_PLANES, 1L, &cColorPlanes);
    DevQueryCaps (hdc, CAPS_COLOR_BITCOUNT, 1L, &cColorBitcount);

}
Пример #13
0
HDC   PrnOpenDC(os2PrintQ *pInfo, PCSZ pszApplicationName,
                int copies, int destination, char *file )
{
  PCSZ pszLogAddress;
  PCSZ pszDataType;
  LONG dcType;
  DEVOPENSTRUC dop;

  if (!pInfo || !pszApplicationName)
    return 0;

  if (destination != printToFile) {
    pszLogAddress = pInfo->QueueName();
    pszDataType = "PM_Q_STD";

    if (destination == printPreview)
      dcType = OD_METAFILE;
    else
      dcType = OD_QUEUED;
  } else {
    if (file && *file)
      pszLogAddress = (PSZ)file;
    else
      pszLogAddress = "FILE";

    pszDataType = "PM_Q_RAW";
    dcType = OD_DIRECT;
  }

  dop.pszLogAddress      = const_cast<PSZ>(pszLogAddress);
  dop.pszDriverName      = (char*)pInfo->DriverName();
  dop.pdriv              = pInfo->DriverData();
  dop.pszDataType        = const_cast<PSZ>(pszDataType);
  dop.pszComment         = const_cast<PSZ>(pszApplicationName);
  dop.pszQueueProcName   = const_cast<PSZ>(pInfo->QueueProc());
  dop.pszQueueProcParams = 0;
  dop.pszSpoolerParams   = 0;
  dop.pszNetworkParams   = 0;

  return DevOpenDC(0, dcType, "*", 9, (PDEVOPENDATA)&dop, 0);
}
Пример #14
0
// initializes the window PS and the off-screen buffer
VOID InitPS( const HWND hwnd )
{
    SIZEL g = { 0, 0 };

    /* we are called before the global hwndFrame is valid */
    hwndFrame = WinQueryWindow ( hwnd , QW_PARENT) ;
    wcprintf("Muell: %x", WinGetLastError( hab ) );
    hdcGlob = WinOpenWindowDC( hwnd );
    hpsGlob = GpiCreatePS( hab, hdcGlob, &g, PU_ARBITRARY | GPIT_MICRO |
			   GPIA_ASSOC );
    /*
     * Create our off-screen 'buffer'.
     */
    // hdcGlob als letzten Parameter ist neu:
    hdcBufferGlob = DevOpenDC( (HAB)0L, OD_MEMORY, "*", 0L, NULL, hdcGlob );
    hpsBufferGlob = GpiCreatePS( hab, hdcBufferGlob, &g, PU_ARBITRARY |
				 GPIT_MICRO | GPIA_ASSOC );

    /* get the device resolutions  */
    DevQueryCaps( hdcGlob, CAPS_COLOR_PLANES, 1L, &cColorPlanes );
    DevQueryCaps( hdcGlob, CAPS_COLOR_BITCOUNT, 1L, &cColorBitCount );
}
Пример #15
0
//----------------------------------------------------------------------------
// NPP_DestroyStream:
//----------------------------------------------------------------------------
NPError NP_LOADDS
NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason) {
  if ( instance == 0 ) return NPERR_INVALID_INSTANCE_ERROR;
  PluginInstance* This = (PluginInstance*) instance->pdata;

  if ( reason == NPRES_DONE && This->bufMeta ) {
    // create metafile from buffer

    // 1-st, create empty metafile
    HAB hab=WinQueryAnchorBlock( This->hWnd );
    DEVOPENSTRUC dop;
    dop.pszLogAddress = (PSZ) NULL;
    dop.pszDriverName = "DISPLAY";
    HDC hdcMeta = DevOpenDC( hab,
        OD_METAFILE,                 /* Metafile device context             */
        "*",                         /* Ignores OS2.INI                     */
        2L,                          /* Uses first two fields               */
        (PDEVOPENDATA) &dop,         /* Device information                  */
        (HDC) NULLHANDLE );          /* Compatible device context           */
    SIZEL sizlPage={ 0, 0 };
    HPS hpsMeta = GpiCreatePS( hab, hdcMeta, &sizlPage, PU_PELS | GPIA_ASSOC );
    GpiAssociate( hpsMeta, (HDC)NULLHANDLE );
    HMF hmf = DevCloseDC( hdcMeta );
    GpiDestroyPS( hpsMeta );

    // 2-nd, add real data
    GpiSetMetaFileBits( hmf, 0, This->offMeta, This->bufMeta );
    SelectMetaFile( This, hmf );
  }
  // delete buffer
  if ( This->bufMeta ) {
    free( This->bufMeta );
    This->bufMeta=NULL;
    This->cbMeta=0;
    This->offMeta=0;
  }
  return NPERR_NO_ERROR;
}
Пример #16
0
HBITMAP EXPENTRY sknLoadBitmap( HWND hwnd, PSZ pszFileName )
{
   HBITMAP         ret             = 0;

   SIZEL           sizl            = { 0, 0 };  /* use same page size as device */
   DEVOPENSTRUC    dop             = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
   HAB             hab             = WinQueryAnchorBlock(hwnd);
   HDC             hdc;
   HPS             hps;

   hdc  = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
   hps  = GpiCreatePS(hab, hdc, &sizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC);

   if(hps)
   {
      ret = LoadBitmap(hab,hdc,hps,pszFileName);
      GpiDestroyPS(hps);
   }

   DevCloseDC(hdc);

   return ret;
}
Пример #17
0
static void
_cairo_os2_surface_get_pixels_from_screen (cairo_os2_surface_t *surface,
                                           HPS                  hps_begin_paint,
                                           PRECTL               prcl_begin_paint_rect)
{
    HPS hps;
    HDC hdc;
    HAB hab;
    SIZEL sizlTemp;
    HBITMAP hbmpTemp;
    BITMAPINFO2 bmi2Temp;
    POINTL aptlPoints[4];
    int y;
    unsigned char *pchTemp;

    /* To copy pixels from screen to our buffer, we do the following steps:
     *
     * - Blit pixels from screen to a HBITMAP:
     *   -- Create Memory Device Context
     *   -- Create a PS into it
     *   -- Create a HBITMAP
     *   -- Select HBITMAP into memory PS
     *   -- Blit dirty pixels from screen to HBITMAP
     * - Copy HBITMAP lines (pixels) into our buffer
     * - Free resources
     *
     * These steps will require an Anchor Block (HAB). However,
     * WinQUeryAnchorBlock () documentation says that HAB is not
     * used in current OS/2 implementations, OS/2 deduces all information
     * it needs from the TID. Anyway, we'd be in trouble if we'd have to
     * get a HAB where we only know a HPS...
     * So, we'll simply use a fake HAB.
     */

    hab = (HAB) 1; /* OS/2 doesn't really use HAB... */

    /* Create a memory device context */
    hdc = DevOpenDC (hab, OD_MEMORY,"*",0L, NULL, NULLHANDLE);
    if (!hdc) {
        return;
    }

    /* Create a memory PS */
    sizlTemp.cx = prcl_begin_paint_rect->xRight - prcl_begin_paint_rect->xLeft;
    sizlTemp.cy = prcl_begin_paint_rect->yTop - prcl_begin_paint_rect->yBottom;
    hps = GpiCreatePS (hab,
                       hdc,
                       &sizlTemp,
                       PU_PELS | GPIT_NORMAL | GPIA_ASSOC);
    if (!hps) {
        DevCloseDC (hdc);
        return;
    }

    /* Create an uninitialized bitmap. */
    /* Prepare BITMAPINFO2 structure for our buffer */
    memset (&bmi2Temp, 0, sizeof (bmi2Temp));
    bmi2Temp.cbFix = sizeof (BITMAPINFOHEADER2);
    bmi2Temp.cx = sizlTemp.cx;
    bmi2Temp.cy = sizlTemp.cy;
    bmi2Temp.cPlanes = 1;
    bmi2Temp.cBitCount = 32;

    hbmpTemp = GpiCreateBitmap (hps,
                                (PBITMAPINFOHEADER2) &bmi2Temp,
                                0,
                                NULL,
                                NULL);

    if (!hbmpTemp) {
        GpiDestroyPS (hps);
        DevCloseDC (hdc);
        return;
    }

    /* Select the bitmap into the memory device context. */
    GpiSetBitmap (hps, hbmpTemp);

    /* Target coordinates (Noninclusive) */
    aptlPoints[0].x = 0;
    aptlPoints[0].y = 0;

    aptlPoints[1].x = sizlTemp.cx;
    aptlPoints[1].y = sizlTemp.cy;

    /* Source coordinates (Inclusive) */
    aptlPoints[2].x = prcl_begin_paint_rect->xLeft;
    aptlPoints[2].y = surface->bitmap_info.cy - prcl_begin_paint_rect->yBottom;

    aptlPoints[3].x = prcl_begin_paint_rect->xRight;
    aptlPoints[3].y = surface->bitmap_info.cy - prcl_begin_paint_rect->yTop;

    /* Blit pixels from screen to bitmap */
    GpiBitBlt (hps,
               hps_begin_paint,
               4,
               aptlPoints,
               ROP_SRCCOPY,
               BBO_IGNORE);

    /* Now we have to extract the pixels from the bitmap. */
    pchTemp =
        surface->pixels +
        (prcl_begin_paint_rect->yBottom)*surface->bitmap_info.cx*4 +
        prcl_begin_paint_rect->xLeft*4;
    for (y = 0; y < sizlTemp.cy; y++) {
        /* Get one line of pixels */
        GpiQueryBitmapBits (hps,
                            sizlTemp.cy - y - 1, /* lScanStart */
                            1,                   /* lScans */
                            pchTemp,
                            &bmi2Temp);

        /* Go for next line */
        pchTemp += surface->bitmap_info.cx*4;
    }

    /* Clean up resources */
    GpiSetBitmap (hps, (HBITMAP) NULL);
    GpiDeleteBitmap (hbmpTemp);
    GpiDestroyPS (hps);
    DevCloseDC (hdc);
}
/****************************************************************\
 *
 *--------------------------------------------------------------
 *
 *  Name:ClkCreate()
 *
 *  Purpose:Intialize a newly created client window
 *
 *
 *
 *  Usage:
 *
 *  Method:
 *          -
 *
 *          -
 *          -
 *
 *          -
 *          -
 *
 *  Returns:
 *          1 - if sucessful execution completed
 *          0 - if error
\****************************************************************/
VOID ClkCreate ( HWND hwnd )
{
    LONG cxScreen , cyScreen;  /* screen dimensions */
    LONG xLeft , yBottom ;      /* frame window location */
    ULONG cbBuf;
    LONG cyHeight;
    LONG cxWidth;

    hwndClient = hwnd;

    WinLoadString(hab, NULLHANDLE, IDS_TITLE,  0, (PSZ)szTitle   );
    WinLoadString(hab, NULLHANDLE, IDS_HELPTITLE, 256, (PSZ)szHelpTitle);
    GetCountryDependent();
    /* we are called before the global hwndFrame is valid */
    hwndFrame = WinQueryWindow ( hwnd , QW_PARENT) ;
    hwndTitleBar = WinWindowFromID ( hwndFrame , FID_TITLEBAR ) ;
    hwndSysMenu = WinWindowFromID ( hwndFrame , FID_SYSMENU ) ;
    hwndMinMax = WinWindowFromID ( hwndFrame , FID_MINMAX ) ;

    /* load our menus */
    hwndMenu = WinLoadMenu (hwndFrame, NULLHANDLE, IDR_MAIN);
    /* determine screen dimensions */
    /* open a device context and create a presentation space */

    hdc = WinOpenWindowDC (hwnd);
    hps = GpiCreatePS (hab, hdc, &sizl, PU_ARBITRARY | GPIT_MICRO |
            GPIA_ASSOC);

    /*
     * Create our off-screen 'buffer'.
     */
    hdcBuffer = DevOpenDC ( (HAB)0L, OD_MEMORY, "*", 0L, NULL, hdc);
    hpsBuffer = GpiCreatePS (hab, hdcBuffer, &sizl, PU_ARBITRARY |
                               GPIT_MICRO | GPIA_ASSOC);

    GpiCreateLogColorTable (hpsBuffer, 0, LCOLF_RGB, 0, 0, (PLONG)NULL);

    /* get the device resolutions so we can make the face appear circular */
    DevQueryCaps (hdc, (LONG)CAPS_VERTICAL_RESOLUTION,(LONG) 1L, &cyRes);
    DevQueryCaps (hdc, CAPS_HORIZONTAL_RESOLUTION, 1L, &cxRes);
    DevQueryCaps (hdc, CAPS_COLOR_PLANES, 1L, &cColorPlanes);
    DevQueryCaps (hdc, CAPS_COLOR_BITCOUNT, 1L, &cColorBitcount);

    cxScreen = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
    cyScreen = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);

    /*
     * Calculate an initial window position and size.
     */
    xLeft = cxScreen / 8;
    yBottom = cyScreen / 2;
    cxWidth = cxScreen / 3;
    cyHeight = cyScreen / 2;
    WinSetWindowPos (hwndFrame, NULLHANDLE, xLeft, yBottom,
                       cxWidth, cyHeight,
                       SWP_SIZE | SWP_MOVE | SWP_ACTIVATE);

    cbBuf = sizeof(cp);
    if (!PrfQueryProfileData(HINI_USER, SZ_APPNAME, SZ_KEYNAME, &cp, &cbBuf))
    {
        cp.usMajorTickPref = CLKTM_ALWAYS;
        cp.usMinorTickPref = CLKTM_NOTICONIC;
        cp.clrBackground = 0x00008080;
        cp.clrFace = 0x00008080;
        cp.clrHourHand = RGB_RED;
        cp.clrMinuteHand = RGB_RED;
        cp.fControlsHidden = FALSE;
        cp.usDispMode = DM_TIME | DM_ANALOG | DM_SECONDHAND;
        cp.alarm.uchHour = 0;
        cp.alarm.uchMinutes = 0;
        cp.alarm.usMode = 0;
        SetRGBColors();
        /* position the window and make it visible */
        WinSetWindowPos( hwndFrame , NULLHANDLE ,
                           xLeft , yBottom ,
                           cxWidth , cyHeight ,
                           SWP_SIZE | SWP_MOVE | SWP_ACTIVATE);
        WinQueryWindowPos(hwndFrame, &cp.swp);
    }
    else
    { /*Protect against garbage swp*/

        cp.swp.hwnd = hwndFrame;
        cp.swp.hwndInsertBehind = HWND_TOP;

        cp.swp.fl = (cp.swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE)) | SWP_SIZE | SWP_MOVE | SWP_ACTIVATE;
        SetRGBColors();
        WinSetMultWindowPos(hab, &cp.swp, 1);
    }

    if (cp.fControlsHidden)
        ClkHideFrameControls (hwndFrame);

    /*
     * Check relevant items.
     */
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TIME, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_TIME)?  MIA_CHECKED
                                      : ~MIA_CHECKED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_DATE, TRUE),
                MPFROM2SHORT( MIA_DISABLED,
                              ( (!(cp.usDispMode & DM_TIME))?  MIA_DISABLED
                                      : ~MIA_DISABLED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_DATE, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_DATE)?  MIA_CHECKED
                                      : ~MIA_CHECKED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TIME, TRUE),
                MPFROM2SHORT( MIA_DISABLED,
                              ( ((!(cp.usDispMode & DM_DATE) || (cp.usDispMode & DM_ANALOG)))?  MIA_DISABLED
                                      : ~MIA_DISABLED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( (cp.usDispMode & DM_DIGITAL)
                                                          ?IDM_DIGITAL
                                                          :IDM_ANALOG,
                               TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              MIA_CHECKED));

    WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(IDM_SECONDHAND, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_SECONDHAND) ? MIA_CHECKED
                                      : ~MIA_CHECKED)));


    /*
     * Disable these items if the digital clock is visible
     * since they won't apply.
     */
    if (cp.usDispMode & DM_DIGITAL)
    {
        WinSendMsg (hwndMenu, MM_SETITEMATTR,
                MPFROM2SHORT(IDM_SECONDHAND, TRUE),
                MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));

        WinSendMsg (hwndMenu, MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TICKS, TRUE), MPFROM2SHORT( MIA_DISABLED,
                MIA_DISABLED));
    }

    /* have we been asked to start as an icon? */
    if (fStartAsIcon)
        WinSetWindowPos(hwndFrame, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE);

    WinShowWindow(hwndFrame, TRUE);

    /* get the time in a format for dislaying */
    DosGetDateTime(&dt);
    dt.hours = (UCHAR )(dt.hours * (UCHAR) 5) % (UCHAR) 60 + dt.minutes / (UCHAR)12;

    /* start a timer */
    WinStartTimer (hab, hwnd, IDR_MAIN, 1000);

    WinLoadString(hab, NULLHANDLE, IDS_TITLE, 80, (PSZ)szTitle);
    GetCountryDependent();

}
Пример #19
0
HBITMAP PSBMBLTToSize( HAB hab, HPS hps, HBITMAP hbm, float fScale, ULONG ulOptions )
{
    BITMAPINFOHEADER2   bif2Before;
    BITMAPINFOHEADER2   bif2After;
    SIZEL               slAfter;
    ULONG               ulScreenWidth;
    ULONG               ulScreenHeight;
    HDC                 hdcAfter;
    HPS                 hpsAfter;
    HBITMAP             hbmAfter;
    POINTL              aptl[ 4 ];
    float               fAspect;
    HBITMAP             hbmOld;

    if( ( hbmOld = GpiSetBitmap( hps, hbm ) ) == HBM_ERROR )
    {
        return( NULLHANDLE );
    }

    memset( &bif2Before, 0, sizeof( bif2Before ) );                 // get current info
    bif2Before.cbFix = sizeof( bif2Before );
    if( GpiQueryBitmapInfoHeader( hbm, &bif2Before ) != TRUE )
    {
        GpiSetBitmap( hps, hbmOld );
        return( NULLHANDLE );
    }

    ulScreenWidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );  // screen width
    ulScreenHeight = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); // screen height

    fAspect = ( bif2Before.cx * 1.0 ) / ( bif2Before.cy * 1.0 );    // calculate aspect ratio

    if( ulOptions & SCALE_LARGEST )
    {
        if( bif2Before.cx > bif2Before.cy )
        {
            slAfter.cx = ( LONG )( ulScreenWidth * fScale );
            slAfter.cy = ( LONG )( slAfter.cx / fAspect );
        }
        else
        {
            slAfter.cy = ( LONG )( ulScreenHeight * fScale );
            slAfter.cx = ( LONG )( slAfter.cy * fAspect );
        }
    }
    else if( ulOptions & SCALE_SMALLEST )
    {
        if( bif2Before.cx < bif2Before.cy )
        {
            slAfter.cx = ( LONG )( ulScreenWidth * fScale );
            slAfter.cy = ( LONG )( slAfter.cx / fAspect );
        }
        else
        {
            slAfter.cy = ( LONG )( ulScreenHeight * fScale );
            slAfter.cx = ( LONG )( slAfter.cy * fAspect );
        }
    }
    else if( ulOptions & SCALE_HORIZONTAL )
    {
        slAfter.cx = ( LONG )( ulScreenWidth * fScale );
        if( ulOptions & SCALE_VERTICAL )                        // basically, screw the aspect
        {
            slAfter.cy = ( LONG )( ulScreenHeight * fScale );
        }
        else
        {
            slAfter.cy = ( LONG )( slAfter.cx / fAspect );
        }
    }
    else if( ulOptions & SCALE_VERTICAL )
    {
        slAfter.cy = ( LONG )( ulScreenHeight * fScale );
        slAfter.cx = ( LONG )( slAfter.cy * fAspect );
    }
    else
    {
        GpiSetBitmap( hps, hbmOld );
        return( NULLHANDLE );
    }

    if( ( hdcAfter = DevOpenDC( hab, OD_MEMORY, "*", 0L, ( PDEVOPENDATA )NULL, NULLHANDLE ) )
        == NULLHANDLE )
    {
        GpiSetBitmap( hps, hbmOld );
        return( NULLHANDLE );
    }
    if( ( hpsAfter = GpiCreatePS(   hab,
                                    hdcAfter,
                                    &slAfter,
                                    PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC ) ) == NULLHANDLE )
    {
        DevCloseDC( hdcAfter );
        GpiSetBitmap( hps, hbmOld );
        return( NULLHANDLE );
    }

    memset( &bif2After, 0, sizeof( bif2After ) );
    bif2After.cbFix = sizeof( bif2After );
    bif2After.cx = slAfter.cx;
    bif2After.cy = slAfter.cy;
    bif2After.cBitCount = bif2Before.cBitCount;
    bif2After.cPlanes = bif2Before.cPlanes;

    if( ( hbmAfter = GpiCreateBitmap(   hpsAfter,                 // create bitmap
                                        ( PBITMAPINFOHEADER2 )&( bif2After ),
                                        ( ULONG )FALSE,
                                        NULL,
                                        NULL ) ) == NULLHANDLE )
    {
        GpiDestroyPS( hpsAfter );
        DevCloseDC( hdcAfter );
        GpiSetBitmap( hps, hbmOld );
        return( NULLHANDLE );
    }

    if( GpiSetBitmap( hpsAfter, hbmAfter ) == HBM_ERROR )
    {
        GpiDeleteBitmap( hbmAfter );
        GpiDestroyPS( hpsAfter );
        DevCloseDC( hdcAfter );
        GpiSetBitmap( hps, hbmOld );
        return( NULLHANDLE );
    }

    aptl[ 0 ].x = 0;
    aptl[ 0 ].y = 0;
    aptl[ 1 ].x = slAfter.cx;
    aptl[ 1 ].y = slAfter.cy;
    aptl[ 2 ].x = 0;
    aptl[ 2 ].y = 0;
    aptl[ 3 ].x = bif2Before.cx;
    aptl[ 3 ].y = bif2Before.cy;

    if( GpiBitBlt(  hpsAfter,
                    hps,
                    4L,
                    aptl,
                    ROP_SRCCOPY,
                    BBO_IGNORE ) == GPI_ERROR )
    {
        GpiSetBitmap( hpsAfter, NULLHANDLE );
        GpiDeleteBitmap( hbmAfter );
        GpiDestroyPS( hpsAfter );
        DevCloseDC( hdcAfter );
        GpiSetBitmap( hps, hbmOld );
        return( NULLHANDLE );
    }

    GpiSetBitmapDimension( hbmAfter, &slAfter );

    GpiSetBitmap( hpsAfter, NULLHANDLE );
    GpiDestroyPS( hpsAfter );
    DevCloseDC( hdcAfter );
    GpiSetBitmap( hps, hbmOld );

    return( hbmAfter );
}
Пример #20
0
HBITMAP     CreateThumbnailBmp( CAMRecPtr pcr, char * pBuf)

{
    HBITMAP             hBmp = 0;
    uint32_t            ctr;
    HDC                 hdc = 0;
    HPS                 hps = 0;
    char *              pErr = 0;
    BITMAPINFOHEADER2 * pbmih = 0;
    RGB2 *              pRGB;
    SIZEL               sizl;
    CAMJThumb           cjt;

do {
    // decode the JPEG data from the camera
    memset( &cjt, 0, sizeof(cjt));
    cjt.pSrc = pBuf;
    cjt.cbSrc = pcr->tnsize;
    ctr = JpgDecodeThumbnail( &cjt);
    if (ctr) {
        printf( "JpgDecodeThumbnail - rc= 0x%x\n", (int)ctr);
        break;
    }

    // allocate a BITMAPINFOHEADER2 / BITMAPINFO2
    // suitable for 24-bit color or 8-bit grayscale
    ctr = sizeof(BITMAPINFOHEADER2);
    if (cjt.cbPix == 1)
        ctr += 256 * sizeof(RGB2);
        
    pbmih = (BITMAPINFOHEADER2*)malloc( ctr);
    memset( pbmih, 0, ctr);

    // if grayscale, create a default colormap
    if (cjt.cbPix == 1)
        for (ctr = 0, pRGB = (RGB2*)&pbmih[1]; ctr < 256; ctr++, pRGB++) {
            pRGB->bBlue  = ctr;
            pRGB->bGreen = ctr;
            pRGB->bRed   = ctr;
        }

    // init the BMIH
    pbmih->cbFix         = sizeof(BITMAPINFOHEADER2);
    pbmih->cx            = cjt.cxDst;
    pbmih->cy            = cjt.cyDst;
    pbmih->cPlanes       = 1;
    pbmih->cBitCount     = cjt.cbPix * 8;
    pbmih->ulCompression = BCA_UNCOMP;
    pbmih->cbImage       = cjt.cbDst;

    // create a memory DC
    hdc = DevOpenDC( 0, OD_MEMORY, "*", 0L, 0, 0);
    if (!hdc) {
        pErr = "DevOpenDC";
        break;
    }

    // create a square PS using the longer side so we can
    // reuse the PS if we have to rotate the bitmap
    sizl.cx = ((pbmih->cx >= pbmih->cy) ? pbmih->cx : pbmih->cy);
    sizl.cy = sizl.cx;

    hps = GpiCreatePS( 0, hdc, &sizl, PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);
    if (!hps) {
        pErr = "GpiCreatePS";
        break;
    }

    // create a bitmap from the data
    hBmp = GpiCreateBitmap( hps, pbmih, CBM_INIT, cjt.pDst, (BITMAPINFO2*)pbmih);
    if (!hBmp) {
        pErr = "GpiCreateBitmap";
        break;
    }

    // if the bitmap should be rotated, replace the original one
    if (STAT_GETROT(pcr->status)) {
        HBITMAP hBmpRot = RotateBitmap( hps, hBmp, pbmih,
                                        STAT_GETROT(pcr->status));
        if (hBmpRot) {
            GpiDeleteBitmap( hBmp);
            hBmp = hBmpRot;
        }
    }

} while (0);

    if (pErr)
        printf( "CreateThumbnailBmp - %s failed\n", pErr);

    if (hps) {
        GpiSetBitmap( hps, 0);
        GpiDestroyPS( hps);
    }
    if (hdc)
        DevCloseDC( hdc);
    if (pbmih)
        free( pbmih);
    if (cjt.pDst)
        free( cjt.pDst);

    return (hBmp);
}
Пример #21
0
VOID PMfrWriteClipbrdBmp(HAB hab)
   {

   HDC hdcClip;         /* memory DC and PS to extract from the clipboard */
   HPS hpsClip;
   HBITMAP hbmClip;
   SIZEL sizl;
   BITMAPINFOHEADER bmp;
   ULONG _far *alRGBColors;
   LONG errorcode;
   char _far *fp1;
   char _far *fp2;
   int i;

   if (WinOpenClipbrd(hab))
      {
      /* get the memory DC and PS to copy the bitmap */
      hdcClip = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULL) ;

      sizl.cx = cp.cx; sizl.cy = cp.cy;

      hpsClip = GpiCreatePS (hab, hdcClip, &sizl,
                   PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);

      bmp.cbFix   = sizeof bmp;
      bmp.cx      = cp.cx;
      bmp.cy      = cp.cy;
      bmp.cPlanes = cp.cPlanes;
      bmp.cBitCount = cp.cBitCount;
      hbmClip = GpiCreateBitmap (hpsClip, &bmp, 0L, NULL, NULL);

      GpiSetBitmap(hpsClip, hbmClip);

      /* initialize and black out the bitmap */
      alRGBColors = (ULONG _far *) _fmalloc(sizeof(ULONG) * cp.colors);
      /* beginning of source array */
      fp2 = (char _far *) &cp.pbmiMemory->argbColor[0];
      /* beginning of dest array */
      fp1 = (char _far *) &alRGBColors[0];
      for (i = 0; i < cp.colors; i++)
          {   /* copy base bytes for number of screen colors */
          alRGBColors[i] = 0;
          _fmemcpy(fp1, fp2, sizeof(RGB) );
          fp1 += sizeof(ULONG);
          fp2 += sizeof(RGB);
          }

      GpiSetMix ( hpsClip, FM_OVERPAINT) ;
      GpiSetBackMix (hpsClip, BM_LEAVEALONE) ;
      GpiCreateLogColorTable(hpsClip, LCOL_RESET | LCOL_REALIZABLE,
              LCOLF_CONSECRGB, 0L, cp.colors, alRGBColors);

      /* now copy the bits */
      cp.pbmiMemory->cx = cp.cx;
      cp.pbmiMemory->cy = cp.cy;
      cp.pbmiMemory->cPlanes = cp.cPlanes;
      cp.pbmiMemory->cBitCount = cp.cBitCount;
      errorcode = GpiSetBitmapBits(hpsClip, 0L, (LONG) cp.cy,
                                cp.pixels, cp.pbmiMemory);

      /* unlink the new bitmap */
      GpiSetBitmap(hpsClip, (HBITMAP) NULL);

      /* write to the clipboard */
      WinEmptyClipbrd (hab);
      WinSetClipbrdData (hab, (ULONG) hbmClip, CF_BITMAP, CFI_HANDLE);

      /* now clean up */

      _ffree(alRGBColors);
      GpiDestroyPS(hpsClip);
      DevCloseDC(hdcClip);

      WinCloseClipbrd(hab);
      }

   }
Пример #22
0
// *******************************************************************************
// FUNCTION:     GetBitmapFromTrack
//
// FUNCTION USE: Creates a bitmap from a rectangle structure
//
// DESCRIPTION:  This function takes the rectangle structure that is created 
//               as a result of the tracking operation and creates a bitmap 
//               of that area.  
//
// PARAMETERS:   RECTL    tracking rectangle
//
// RETURNS:      HBITMAP  bitmap handle
//
// INTERNALS:    NONE
//
// HISTORY:
//
// *******************************************************************************
HBITMAP GetBitmapFromTrack (RECTL rclTrack)
{
 HAB                hab;                           
 HBITMAP            hbmTrack;
 HDC                hdcMemory;
 HPS                hpsMemory;
 HPS                hpsScreen;
 LONG               lFormats[2];
 POINTL             aptl[3];
 SIZEL              sizl;
 BITMAPINFOHEADER2  bmp2;

 // --------------------------------------------------------------------------                    
 // Get an anchor block handle                                                                    
 // --------------------------------------------------------------------------                    
 hab = WinQueryAnchorBlock(HWND_DESKTOP);

 // --------------------------------------------------------------------------                    
 // Get a memory device context                                                                  
 // --------------------------------------------------------------------------                    
 hdcMemory = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULLHANDLE) ;

 // --------------------------------------------------------------------------                    
 // Set presentation space size                                                                
 // --------------------------------------------------------------------------                    
 sizl.cx = sizl.cy = 0 ;

 // --------------------------------------------------------------------------                             
 // Create a micro presentation space and associate it                                                                           
 // --------------------------------------------------------------------------                             
 hpsMemory = GpiCreatePS (hab,
                          hdcMemory,
                          &sizl,
                          PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);

 // --------------------------------------------------------------------------           
 // Call GpiQueryDeviceBitmapFormats to get the number of bit planes                                   
 // --------------------------------------------------------------------------           
 GpiQueryDeviceBitmapFormats (hpsMemory,
                              2L,
                              lFormats);

 // --------------------------------------------------------------------------        
 // Initialize the bitmap info header structure                 
 // --------------------------------------------------------------------------        
 memset(&bmp2, 0, sizeof(BITMAPINFOHEADER2));

 // --------------------------------------------------------------------------                     
 // Populate the bitmap info header structure                                                    
 // --------------------------------------------------------------------------                     
 bmp2.cbFix     = sizeof bmp2;
 bmp2.cx        = (rclTrack.xRight - rclTrack.xLeft);
 bmp2.cy        = (rclTrack.yTop   - rclTrack.yBottom);
 bmp2.cPlanes   = lFormats[0];
 bmp2.cBitCount = lFormats[1];

 // --------------------------------------------------------------------------         
 // Create a bitmap representing the tracking rectangle                                
 // --------------------------------------------------------------------------         
 hbmTrack = GpiCreateBitmap (hpsMemory, &bmp2, 0L, NULL, NULL);

 if (hbmTrack == GPI_ERROR)
  {
   return GPI_ERROR;
  }

 else
  {
   // --------------------------------------------------------------------------        
   // Set the bitmap into our memory presentation space.                                                                      
   // --------------------------------------------------------------------------        
   GpiSetBitmap (hpsMemory, hbmTrack);
   hpsScreen = WinGetScreenPS (HWND_DESKTOP);
  
   aptl[0].x = 0;
   aptl[0].y = 0;
   aptl[1].x = bmp2.cx;
   aptl[1].y = bmp2.cy;
   aptl[2].x = rclTrack.xLeft;
   aptl[2].y = rclTrack.yBottom;
  
   WinLockVisRegions (HWND_DESKTOP, TRUE);
  
   // --------------------------------------------------------------------------                 
   // Bit blit the contents of the source presentation space into our target                     
   // presentation space.  This is how we copy the bitmap from the source to                     
   // the target.                                                                                
   // --------------------------------------------------------------------------                 
   GpiBitBlt (hpsMemory,      //  Target presentation space handle           
              hpsScreen,      //  Source presentation space handle           
              3L,             //  Number of Points                           
              aptl,           //  Array of Points                            
              ROP_SRCCOPY,    //  Mixing function (source copy)              
              BBO_IGNORE);    //  Options                                    
  
   WinLockVisRegions (HWND_DESKTOP, FALSE);
   WinReleasePS (hpsScreen);
  }

 // --------------------------------------------------------------------------                  
 // Free Graphics Engine Resources 
 // --------------------------------------------------------------------------                  
 GpiDestroyPS (hpsMemory);
 DevCloseDC (hdcMemory);

 // --------------------------------------------------------------------------                  
 // Return bitmap handle           
 // --------------------------------------------------------------------------                  
 return hbmTrack;
}
Пример #23
0
// *******************************************************************************                      
// FUNCTION:     DuplicateBitmap                                                                           
//                                                                                                      
// FUNCTION USE: Duplicates a bitmap                                                                        
//                                                                                                      
// DESCRIPTION:  Uses GpiBitBlt to make a copy of a bitmap by bit-bliting the 
//               contents of the source PS containing the bitmap, to the target 
//               presentation space.
//                                                                                                      
// PARAMETERS:   HBITMAP    source bitmap handle to copy                                              
//                                                                                                      
// RETURNS:      HBITMAP    target bitmap handle                                                                                                                      
//                                                                                                      
// HISTORY:                                                                                             
//                                                                                                      
// *******************************************************************************                      
HBITMAP DuplicateBitmap (HBITMAP hbmSource)                                                    
{                                                                                 
 HAB                hab;
 HBITMAP            hbmTarget;                                                        
 HDC                hdcSource;                                                
 HDC                hdcTarget;
 HPS                hpsSource;                                                
 HPS                hpsTarget;
 SIZEL              sizl;         
 POINTL             aptl[3];                                                       
 BOOL               bError = FALSE;
 BITMAPINFOHEADER2  bmp2;                                                           

 // --------------------------------------------------------------------------                      
 // Get an anchor block handle                                                                     
 // --------------------------------------------------------------------------                      
 hab = WinQueryAnchorBlock(HWND_DESKTOP);
                                                                                   
 // --------------------------------------------------------------------------                       
 // Create memory device context handles and presentation space handles                                                                      
 // --------------------------------------------------------------------------                       
 hdcSource = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULLHANDLE);                  
 hdcTarget = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULLHANDLE);                  
                                                                                   
 // --------------------------------------------------------------------------              
 // Set presentation space size                                                            
 // --------------------------------------------------------------------------              
 sizl.cx = 0;                                                         
 sizl.cy = 0;                                                            

 // --------------------------------------------------------------------------            
 // Create our source presentation space                                                           
 // --------------------------------------------------------------------------            
 hpsSource = GpiCreatePS (hab,        
                          hdcSource, 
                          &sizl,                                
                          PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);                    
                                                                                   
 // --------------------------------------------------------------------------                
 // Create our target presentation space                                                      
 // --------------------------------------------------------------------------                
 hpsTarget = GpiCreatePS (hab, 
                          hdcTarget,                  
                          &sizl,
                          PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);   
                                                                                   

 // --------------------------------------------------------------------------                   
 // Initialize the bitmap info header structure                                                        
 // --------------------------------------------------------------------------                                                                                    
// memset(&bmp2, NULL, sizeof(BITMAPINFOHEADER2));           

 // --------------------------------------------------------------------------         
 // Set the size of the structure                                                      
 // --------------------------------------------------------------------------         
 bmp2.cbFix = sizeof (BITMAPINFOHEADER2);                                          

 // --------------------------------------------------------------------------        
 // Get the bitmap information header from the source bitmap                                      
 // --------------------------------------------------------------------------        
 GpiQueryBitmapInfoHeader (hbmSource, &bmp2);                                         

 // --------------------------------------------------------------------------          
 // Create our target bitmap using the bitmap information header from                                                   
 // our source bitmap.
 // --------------------------------------------------------------------------          
 hbmTarget = GpiCreateBitmap (hpsTarget, &bmp2, 0L, NULL, NULL);                         
                                                                                   
 // --------------------------------------------------------------------------                                                 
 // If everything is cool, set the bitmaps into our presentation spaces.                
 // --------------------------------------------------------------------------                   
 if (hbmTarget != GPI_ERROR)                     
  {                                                                            
   GpiSetBitmap (hpsSource, hbmSource);                                              
   GpiSetBitmap (hpsTarget, hbmTarget);                                              
                                                                                   
   aptl[0].x = 0;                                                  
   aptl[0].y = 0;
   aptl[1].x = bmp2.cx;                                                         
   aptl[1].y = bmp2.cy;                                                         
   aptl[2].x = 0;                                                        
   aptl[2].y = 0;
                                                                                   
   // --------------------------------------------------------------------------        
   // Bit blit the contents of the source presentation space into our target           
   // presentation space.  This is how we copy the bitmap from the source to 
   // the target.
   // --------------------------------------------------------------------------        
   bError = GpiBitBlt (hpsTarget,      //  Target presentation space handle                    
                       hpsSource,      //  Source presentation space handle                
                       3L,             //  Number of Points                                
                       aptl,           //  Array of Points                                 
                       ROP_SRCCOPY,    //  Mixing function (source copy)         
                       BBO_IGNORE);    //  Options                                         

   // --------------------------------------------------------------------------                   
   // If we get an error copying from our source PS to our target PS                          
   // set the error flag to TRUE so that we can return GPI_ERROR back                              
   // to the caller.
   // --------------------------------------------------------------------------                   
   if (bError == GPI_ERROR) 
    {
     bError = TRUE;
    }

   // --------------------------------------------------------------------------                
   // If we got a value back from GpiBitBlt reset our error flag since                            
   // bError would be TRUE.
   // --------------------------------------------------------------------------                
   else
    {
     bError = FALSE;
    }
  }                                                                            

 // --------------------------------------------------------------------------            
 // If we get an error creating the bitmap set the bError flag to TRUE      
 // so we can return GPI_ERROR telling the caller that the function failed.
 // --------------------------------------------------------------------------            
 else
  {
   bError = TRUE;
  }

 // --------------------------------------------------------------------------                           
 // Regardless of what happens, we will free all of our graphics engine                            
 // resources by destroying our presentation spaces and device context 
 // handles.
 // --------------------------------------------------------------------------                           
 GpiDestroyPS (hpsSource);                                                           
 GpiDestroyPS (hpsTarget);                                                           
 DevCloseDC (hdcSource);                                                             
 DevCloseDC (hdcTarget);                                                             

 // --------------------------------------------------------------------------              
 // If we get an error trying to duplicate the bitmap, return GPI_ERROR.                   
 // --------------------------------------------------------------------------              
 if (bError) 
  {
   return GPI_ERROR;
  } 

 // --------------------------------------------------------------------------                          
 // If everthing worked like a champ, return the bitmap handle.                                        
 // --------------------------------------------------------------------------                          
 else
  {
   return hbmTarget;                                                                   
  }
}                                                                                 
  static
  grPMSurface*  init_surface( grPMSurface*  surface,
                              grBitmap*     bitmap )
  {
    PBITMAPINFO2  bit;
    SIZEL         sizl = { 0, 0 };
    LONG          palette[256];
    LOG(( "Os2PM: init_surface( %08lx, %08lx )\n",
          (long)surface, (long)bitmap ));

    LOG(( "       -- input bitmap =\n" ));
    LOG(( "       --   mode   = %d\n", bitmap->mode ));
    LOG(( "       --   grays  = %d\n", bitmap->grays ));
    LOG(( "       --   width  = %d\n", bitmap->width ));
    LOG(( "       --   height = %d\n", bitmap->rows ));

    /* create the bitmap - under OS/2, we support all modes as PM */
    /* handles all conversions automatically..                    */
    if ( grNewBitmap( bitmap->mode,
                      bitmap->grays,
                      bitmap->width,
                      bitmap->rows,
                      bitmap ) )
      return 0;

    LOG(( "       -- output bitmap =\n" ));
    LOG(( "       --   mode   = %d\n", bitmap->mode ));
    LOG(( "       --   grays  = %d\n", bitmap->grays ));
    LOG(( "       --   width  = %d\n", bitmap->width ));
    LOG(( "       --   height = %d\n", bitmap->rows ));

    bitmap->pitch = -bitmap->pitch;
    surface->root.bitmap = *bitmap;

    /* create the image and event lock */
    DosCreateEventSem( NULL, &surface->event_lock, 0, TRUE  );
    DosCreateMutexSem( NULL, &surface->image_lock, 0, FALSE );

    /* create the image's presentation space */
    surface->image_dc = DevOpenDC( gr_anchor,
                                   OD_MEMORY, (PSZ)"*", 0L, 0L, 0L );

    surface->image_ps = GpiCreatePS( gr_anchor,
                                     surface->image_dc,
                                     &sizl,
                                     PU_PELS    | GPIT_MICRO |
                                     GPIA_ASSOC | GPIF_DEFAULT );

    GpiSetBackMix( surface->image_ps, BM_OVERPAINT );

    /* create the image's PM bitmap */
    bit = (PBITMAPINFO2)grAlloc( sizeof(BITMAPINFO2) + 256*sizeof(RGB2) );
    surface->bitmap_header = bit;

    bit->cbFix   = sizeof( BITMAPINFOHEADER2 );
    bit->cx      = surface->root.bitmap.width;
    bit->cy      = surface->root.bitmap.rows;
    bit->cPlanes = 1;

    bit->argbColor[0].bBlue  = 255;
    bit->argbColor[0].bGreen = 0;
    bit->argbColor[0].bRed   = 0;

    bit->argbColor[1].bBlue  = 0;
    bit->argbColor[1].bGreen = 255;
    bit->argbColor[1].bRed   = 0;

    bit->cBitCount = (bitmap->mode == gr_pixel_mode_gray ? 8 : 1 );

    if (bitmap->mode == gr_pixel_mode_gray)
    {
      RGB2*  color = bit->argbColor;
      int    x, count;

      count = bitmap->grays;
      for ( x = 0; x < count; x++, color++ )
      {
        color->bBlue  =
        color->bGreen =
        color->bRed   = (((count-x)*255)/count);
      }
    }
    else
    {
      RGB2*  color = bit->argbColor;

      color[0].bBlue  =
      color[0].bGreen =
      color[0].bRed   = 0;

      color[1].bBlue  =
      color[1].bGreen =
      color[1].bRed   = 255;
    }

    surface->os2_bitmap = GpiCreateBitmap( surface->image_ps,
                                           (PBITMAPINFOHEADER2)bit,
                                           0L, NULL, NULL );

    GpiSetBitmap( surface->image_ps, surface->os2_bitmap );

    bit->cbFix = sizeof( BITMAPINFOHEADER2 );
    GpiQueryBitmapInfoHeader( surface->os2_bitmap,
                              (PBITMAPINFOHEADER2)bit );
    surface->bitmap_header = bit;

    /* for gr_pixel_mode_gray, create a gray-levels logical palette */
    if ( bitmap->mode == gr_pixel_mode_gray )
    {
      int     x, count;

      count = bitmap->grays;
      for ( x = 0; x < count; x++ )
        palette[x] = (((count-x)*255)/count) * 0x010101;

      /* create logical color table */
      GpiCreateLogColorTable( surface->image_ps,
                              (ULONG) LCOL_PURECOLOR,
                              (LONG)  LCOLF_CONSECRGB,
                              (LONG)  0L,
                              (LONG)  count,
                              (PLONG) palette );

      /* now, copy the color indexes to surface->shades */
      for ( x = 0; x < count; x++ )
        surface->shades[x] = GpiQueryColorIndex( surface->image_ps,
                                                 0, palette[x] );
    }

    /* set up the blit points array */
    surface->blit_points[1].x = surface->root.bitmap.width;
    surface->blit_points[1].y = surface->root.bitmap.rows;
    surface->blit_points[3]   = surface->blit_points[1];

    /* Finally, create the event handling thread for the surface's window */
    DosCreateThread( &surface->message_thread,
                     (PFNTHREAD) RunPMWindow,
                     (ULONG)     surface,
                     0UL,
                     32920 );

    /* wait for the window creation */
    LOCK(surface->image_lock);
    UNLOCK(surface->image_lock);

    surface->root.done         = (grDoneSurfaceFunc) done_surface;
    surface->root.refresh_rect = (grRefreshRectFunc) refresh_rectangle;
    surface->root.set_title    = (grSetTitleFunc)    set_title;
    surface->root.listen_event = (grListenEventFunc) listen_event;

    /* convert_rectangle( surface, 0, 0, bitmap->width, bitmap->rows ); */
    return surface;
  }
BOOL CandyBarZFrameBorderPaintProc(HWND hwnd, RECTL * rect, HPS hpsFrame, short sState)
{
    CBZDATA     *pCBZData;
    CBZSHARE    *pCBZShare;
    PSPAINT     *pPaint;
    TEMPPAINT   *pFramePaint;
    BOOL        rc;
    int         i;
    ULONG       ulDataOffset;

    if (DosGetNamedSharedMem((PPVOID) & pCBZShare, CBZ_SHARE,  PAG_READ) != NO_ERROR)
    {
        return (FALSE);
    }
    ulDataOffset = pCBZShare->ulDataOffset;
    DosFreeMem(pCBZShare);

    // get window data
    if ((pCBZData = WinQueryWindowPtr(CandyBarZGetTopLevelFrameHWND(hwnd), ulDataOffset)) == NULL
            || !pCBZData->bFrameBorderEnabled  )
    {
        return (FALSE);
    }

    if (pCBZData->sFrameBorderIndex >= pCBZData->sPushButtonIndex)
    {
        return (FALSE);
    }

    // alloc paint struct
    if (DosAllocMem((PPVOID) & pFramePaint,
                    sizeof(TEMPPAINT),
                    PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR)
    {
        return (FALSE);
    }
    memset(pFramePaint, 0, sizeof(TEMPPAINT));

    pFramePaint->hab = WinQueryAnchorBlock(hwnd);

    // alloc paint struct
    if (DosAllocMem((PPVOID) & pPaint,
                    sizeof(PSPAINT),
                    PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR)
    {
        DosFreeMem(pFramePaint);
        return (FALSE);
    }
    memset(pPaint, 0, sizeof(PSPAINT));

    //Text plugin needs this for quering presentation parameters.
    pPaint->hwnd = hwnd;

    // entire window
    pPaint->rectlWindow = pPaint->rectlUpdate = *rect;

    // get PS
    pPaint->hpsWin = hpsFrame;

    // we will blt and draw gradient text into the hps associated with this dc
    if ((pFramePaint->hdc = DevOpenDC(pFramePaint->hab, OD_MEMORY, "*", 0L, (PDEVOPENDATA) NULL, NULLHANDLE))
            == NULLHANDLE)
    {
        DosFreeMem(pPaint);
        DosFreeMem(pFramePaint);
        return (FALSE);
    }
    // create hps2 for hdc2.  hps for hdc depends on size of bitmap, so it's not created until
    // we know if it's active or not.  create for size of window, then we blt only portion
    // needed
    pFramePaint->slHPS.cx = pPaint->rectlWindow.xRight;
    pFramePaint->slHPS.cy = pPaint->rectlWindow.yTop;

    if ((pPaint->hps = GpiCreatePS(pFramePaint->hab,
                                   pFramePaint->hdc,
                                   &(pFramePaint->slHPS),
                          PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC))
            == NULLHANDLE)
    {
        DevCloseDC(pFramePaint->hdc);
        DosFreeMem(pPaint);
        DosFreeMem(pFramePaint);
        return (FALSE);
    }

    pFramePaint->bif2.cbFix = sizeof(BITMAPINFOHEADER2);
    pFramePaint->bif2.cx = pPaint->rectlWindow.xRight;
    pFramePaint->bif2.cy = pPaint->rectlWindow.yTop;
    pFramePaint->bif2.cBitCount = 24;
    pFramePaint->bif2.cPlanes = 1;
    if ((pFramePaint->hbmTemp = GpiCreateBitmap(pPaint->hps,  // create bitmap
                                 (PBITMAPINFOHEADER2) & (pFramePaint->bif2),
                                                (ULONG) 0,
                                                (PSZ) NULL,
                       (PBITMAPINFO2) & (pFramePaint->bif2))) == NULLHANDLE)
    {
        GpiDestroyPS(pPaint->hps);
        DevCloseDC(pFramePaint->hdc);
        DosFreeMem(pPaint);
        DosFreeMem(pFramePaint);
        return (FALSE);
    }
    if (GpiSetBitmap(pPaint->hps, pFramePaint->hbmTemp) == HBM_ERROR)
    {
        GpiDeleteBitmap(pFramePaint->hbmTemp);
        GpiDestroyPS(pPaint->hps);
        DevCloseDC(pFramePaint->hdc);
        DosFreeMem(pPaint);
        DosFreeMem(pFramePaint);
        return (FALSE);
    }

    // set color table into rgb mode.  otherwise colors between 0 and
    // 15 are interpreted as indexes
    GpiCreateLogColorTable(pPaint->hps, 0, LCOLF_RGB, 0, 0, NULL);

    {
        //fill ps with default bg color...
        ULONG attrFound;
        long lColor;
        if ( (WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, &attrFound, sizeof(attrFound),
                                                &lColor, QPF_PURERGBCOLOR)) == 0 )
           lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
        // fill with default color
        WinFillRect(pPaint->hps, &(pPaint->rectlUpdate), lColor);
    }

    // call Plugins Paint Procedures here
    for (i = pCBZData->sFrameBorderIndex; i < pCBZData->sPushButtonIndex; i++)
    {
        if ( !(pCBZData->Plugins[i].pfnPluginRender(pPaint, pCBZData->Plugins[i].pData, sState)) )
        {
            GpiSetBitmap(pPaint->hps, NULLHANDLE);
            GpiDeleteBitmap(pFramePaint->hbmTemp);
            GpiDestroyPS(pPaint->hps);
            DevCloseDC(pFramePaint->hdc);
            DosFreeMem(pPaint);
            DosFreeMem(pFramePaint);
            return (FALSE);
        }
    }


    if ((rc = BltToWindow(pPaint)) == TRUE)
    {
        //paint sucessful, validate the window
//        WinQueryWindowRect(hwnd, &(pPaint->rectlUpdate));
        WinValidateRect(hwnd, &(pPaint->rectlUpdate), FALSE);
    }
    GpiSetBitmap(pPaint->hps, NULLHANDLE);
    GpiDeleteBitmap(pFramePaint->hbmTemp);
    GpiDestroyPS(pPaint->hps);
    DevCloseDC(pFramePaint->hdc);
    DosFreeMem(pPaint);
    DosFreeMem(pFramePaint);

    return (rc);
}
Пример #26
0
 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;
 }
Пример #27
0
 HBITMAP icqskin_createFrameBackground(HWND hwnd, HBITMAP bg, short cx, short cy, HBITMAP *img, HBITMAP *msk)
 {
#ifndef SKINNED_GUI
    return NO_IMAGE;
#else
    SIZEL                sizl    = { 0, 0 };
    DEVOPENSTRUC         dop     = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
    HAB                  hab     = WinQueryAnchorBlock(hwnd);
    HPS                  hps;
    HDC                  hdc;
    BITMAPINFOHEADER     bmpData;
    BITMAPINFOHEADER2    bmih;
    RECTL                rcl;
    int					 x;
    int                  y;
    int                  f;

    icqskin_deleteImage(bg);


    for(f=0;f<ICQFRAME_SKINBITMAPS && img[f] == NO_IMAGE;f++);

    if(f >= ICQFRAME_SKINBITMAPS)
       return NO_IMAGE;

    hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
    hps = GpiCreatePS(hab, hdc, &sizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC);

    bmih.cbFix        = sizeof(bmih);
    bmih.cx           = cx;
    bmih.cy           = cy;
    bmih.cPlanes      = 1;
    bmih.cBitCount    = 24;
    bg                = GpiCreateBitmap(hps, &bmih, 0L, NULL, NULL);

    GpiSetBitmap(hps,bg);

    /* Clear background */
    rcl.xLeft   =
    rcl.yBottom = 0;
    rcl.xRight  = cx;

    rcl.yTop    = cy;

    DBGTrace(cx);
    DBGTrace(cy);

    icqskin_paintBackground(hwnd,hps,&rcl);

    GpiSelectPalette(hps,NULLHANDLE);
    GpiSetColor(hps,CLR_WHITE);
    GpiSetBackColor(hps,CLR_BLACK);

    /* Stretch images */
    y = cy;

    if(img[ICQFRAME_MIDSTRETCH] != NO_IMAGE)
    {
       if(img[ICQFRAME_TITLESTRETCH] != NO_IMAGE)
       {
          GpiQueryBitmapParameters(img[ICQFRAME_TITLESTRETCH], &bmpData);
          y -= bmpData.cy;
       }

       if(img[ICQFRAME_MIDLEFT] == NO_IMAGE)
       {
          x = 0;
       }
       else
       {
          GpiQueryBitmapParameters(img[ICQFRAME_MIDLEFT], &bmpData);
          x = bmpData.cx;
       }

       GpiQueryBitmapParameters(img[ICQFRAME_MIDSTRETCH], &bmpData);
       y -= bmpData.cy;

       do
       {
          for(f=x;f<cx;f+=bmpData.cx)
             drawFrameBG(img,msk, ICQFRAME_MIDSTRETCH, hps, f, y, bmpData.cx, bmpData.cy);
          y -= bmpData.cy;
       } while(y > 0);

    }

    if(img[ICQFRAME_TITLESTRETCH] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_TITLESTRETCH], &bmpData);
       y = cy-bmpData.cy;
       for(x=0; x<cx; x += bmpData.cx)
          drawFrameBG(img,msk, ICQFRAME_TITLESTRETCH, hps, x, y, bmpData.cx, bmpData.cy);
    }

    if(img[ICQFRAME_MIDLEFT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_MIDLEFT], &bmpData);
       drawFrameBG(img,msk, ICQFRAME_MIDLEFT, hps, 0, 0, bmpData.cx, bmpData.cy);
    }

    if(img[ICQFRAME_MIDRIGHT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_MIDRIGHT], &bmpData);
       drawFrameBG(img,msk, ICQFRAME_MIDRIGHT, hps, cx-bmpData.cx, 0, bmpData.cx, bmpData.cy);
    }

    y = cy;
    if(img[ICQFRAME_TITLELEFT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_TITLELEFT], &bmpData);
       y -= bmpData.cy;
       drawFrameBG(img,msk, ICQFRAME_TITLELEFT, hps, 0, y, bmpData.cx, bmpData.cy);
    }

    if(img[ICQFRAME_TOPLEFT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_TOPLEFT], &bmpData);
       y -= bmpData.cy;
       drawFrameBG(img,msk, ICQFRAME_TOPLEFT, hps, 0, y, bmpData.cx, bmpData.cy);
    }


    if(img[ICQFRAME_MIDLEFT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_MIDLEFT], &bmpData);
       while(y > 0)
       {
          y -= bmpData.cy;
          drawFrameBG(img,msk, ICQFRAME_MIDLEFT, hps, 0, y, bmpData.cx, bmpData.cy);
       }
    }

    // Right images
    y = cy;

    if(img[ICQFRAME_TITLERIGHT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_TITLERIGHT], &bmpData);
       y -= bmpData.cy;
       drawFrameBG(img,msk, ICQFRAME_TITLERIGHT, hps, cx-bmpData.cx, y, bmpData.cx, bmpData.cy);
    }

    if(img[ICQFRAME_TOPRIGHT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_TOPRIGHT], &bmpData);
       y -= bmpData.cy;
       drawFrameBG(img,msk, ICQFRAME_TOPRIGHT, hps, cx-bmpData.cx, y, bmpData.cx, bmpData.cy);
    }

    if(img[ICQFRAME_MIDRIGHT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_MIDRIGHT], &bmpData);
       x = cx-bmpData.cx;
       while(y > 0)
       {
          y -= bmpData.cy;
          drawFrameBG(img,msk, ICQFRAME_MIDRIGHT, hps, x, y, bmpData.cx, bmpData.cy);
       }
    }

    // Bottom images
    if(img[ICQFRAME_BOTTOMSTRETCH] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMSTRETCH], &bmpData);
       for(x=0; x<cx; x += bmpData.cx)
          drawFrameBG(img,msk, ICQFRAME_BOTTOMSTRETCH, hps, x, 0, bmpData.cx, bmpData.cy);

    }

    x = 0;
    if(img[ICQFRAME_BOTTOMLEFT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMLEFT], &bmpData);
       x += bmpData.cx;
       drawFrameBG(img,msk, ICQFRAME_BOTTOMLEFT, hps, 0, 0, bmpData.cx, bmpData.cy);
    }

    if(img[ICQFRAME_BOTTOMMIDLEFT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMMIDLEFT], &bmpData);
       drawFrameBG(img,msk, ICQFRAME_BOTTOMMIDLEFT, hps, x, 0, bmpData.cx, bmpData.cy);
    }

    x = cx;
    if(img[ICQFRAME_BOTTOMRIGHT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMRIGHT], &bmpData);
       x -= bmpData.cx;
       drawFrameBG(img,msk, ICQFRAME_BOTTOMRIGHT, hps, x, 0, bmpData.cx, bmpData.cy);
    }

    if(img[ICQFRAME_BOTTOMMIDRIGHT] != NO_IMAGE)
    {
       GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMMIDRIGHT], &bmpData);
       x -= bmpData.cx;
       drawFrameBG(img,msk, ICQFRAME_BOTTOMMIDRIGHT, hps, x, 0, bmpData.cx, bmpData.cy);
    }

    /* Release image */
    GpiSetBitmap(hps, NULLHANDLE);
    GpiDestroyPS(hps);
    DevCloseDC(hdc);

    return bg;
#endif
 }
Пример #28
0
HBITMAP SetupBitmapFromFile(HWND hwnd, char *pszFileName /*, long lVertical2*/)
{
    HAB hab = WinQueryAnchorBlock(hwnd);
    PSTBFILE *pFile;
    HBITMAP hbm;

    if (DosAllocMem((PPVOID) & pFile, sizeof(PSTBFILE), PAG_READ | PAG_WRITE | PAG_COMMIT)
            != NO_ERROR)
    {
        return (NULLHANDLE);
    }
    memset(pFile, 0, sizeof(PSTBFILE));

    if (PSMMFillImageFormat(pszFileName, &(pFile->mmFormat), &(pFile->mmioInfo)) != TRUE)
    {
        DosFreeMem(pFile);
        return (NULLHANDLE);
    }
    if ((pFile->hmmio = PSMMInitializeImageFile(pszFileName,
                                                &(pFile->mmioInfo),
                                         &(pFile->mmImgHdr))) == NULLHANDLE)
    {
        DosFreeMem(pFile);
        return (NULLHANDLE);
    }
    pFile->cbRow = ((pFile->mmImgHdr.mmXDIBHeader.BMPInfoHeader2.cx *
      pFile->mmImgHdr.mmXDIBHeader.BMPInfoHeader2.cBitCount + 31) / 32) * 4;
    pFile->cbData = pFile->cbRow * pFile->mmImgHdr.mmXDIBHeader.BMPInfoHeader2.cy;

    if (DosAllocMem(&(pFile->pvImage), pFile->cbData, PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR)
    {
        PSMMCloseImageFile(pFile->hmmio);
        DosFreeMem(pFile);
        return (NULLHANDLE);
    }
    if (PSMMReadImageFile(pFile->hmmio, pFile->pvImage, pFile->cbData) != TRUE)
    {
        DosFreeMem(pFile->pvImage);
        PSMMCloseImageFile(pFile->hmmio);
        DosFreeMem(pFile);
    }
    PSMMCloseImageFile(pFile->hmmio);

    // convert data to system bitcount
    pFile->hdc = DevOpenDC(hab, OD_MEMORY, "*", 0L, (PDEVOPENDATA) NULL, NULLHANDLE);
    pFile->slHPS.cx = pFile->mmImgHdr.mmXDIBHeader.BMPInfoHeader2.cx;
    pFile->slHPS.cy = pFile->mmImgHdr.mmXDIBHeader.BMPInfoHeader2.cy;
    pFile->hps = GpiCreatePS(hab,
                             pFile->hdc,
                             &(pFile->slHPS),
                          PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);
    pFile->hbm = GpiCreateBitmap(pFile->hps,
                             &(pFile->mmImgHdr.mmXDIBHeader.BMPInfoHeader2),
                                 0L,
                                 NULL,
                                 NULL);
    GpiSetBitmap(pFile->hps, pFile->hbm);
    GpiSetBitmapBits(pFile->hps,
                     0L,
                     (long) pFile->slHPS.cy,
                     (PBYTE) pFile->pvImage,
            (PBITMAPINFO2) & (pFile->mmImgHdr.mmXDIBHeader.BMPInfoHeader2));

    hbm = pFile->hbm;

    GpiDeleteBitmap(pFile->hbm);

    // free everything up
    GpiSetBitmap(pFile->hps, NULLHANDLE);
    GpiDestroyPS(pFile->hps);
    DevCloseDC(pFile->hdc);
    DosFreeMem(pFile->pvImage);
    DosFreeMem(pFile);

    return (hbm);
}
nsresult nsIconChannel::MakeInputStream(nsIInputStream **_retval,
                                        bool nonBlocking)
{

  // get some details about this icon
  nsCOMPtr<nsIFile> localFile;
  uint32_t desiredImageSize;
  nsXPIDLCString contentType;
  nsAutoCString filePath;
  nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile),
                                       &desiredImageSize, contentType,
                                       filePath);
  NS_ENSURE_SUCCESS(rv, rv);

  // if the file exists, get its path
  bool fileExists = false;
  if (localFile) {
    localFile->GetNativePath(filePath);
    localFile->Exists(&fileExists);
  }

  // get the file's icon from either the WPS or PM
  bool fWpsIcon = false;
  HPOINTER hIcon = GetIcon(filePath, fileExists,
                           desiredImageSize <= 16, &fWpsIcon);
  if (hIcon == NULLHANDLE)
    return NS_ERROR_FAILURE;

  // get the color & mask bitmaps used by the icon
  POINTERINFO IconInfo;
  if (!WinQueryPointerInfo(hIcon, &IconInfo)) {
    DestroyIcon(hIcon, fWpsIcon);
    return NS_ERROR_FAILURE;
  }

  // if we need a mini-icon, use those bitmaps if present;
  // otherwise, signal that the icon needs to be shrunk
  bool fShrink = FALSE;
  if (desiredImageSize <= 16) {
    if (IconInfo.hbmMiniPointer) {
      IconInfo.hbmColor = IconInfo.hbmMiniColor;
      IconInfo.hbmPointer = IconInfo.hbmMiniPointer;
    } else {
      fShrink = TRUE;
    }
  }

  // various resources to be allocated
  PBITMAPINFO2  pBMInfo = 0;
  uint8_t*      pInBuf  = 0;
  uint8_t*      pOutBuf = 0;
  HDC           hdc     = 0;
  HPS           hps     = 0;

  // using this dummy do{...}while(0) "loop" guarantees that resources will
  // be deallocated, but eliminates the need for nesting, and generally makes
  // testing for & dealing with errors pretty painless (just 'break')
  do {
    rv = NS_ERROR_FAILURE;

    // get the details for the color bitmap;  if there isn't one
    // or this is 1-bit color, exit
    BITMAPINFOHEADER2  BMHeader;
    BMHeader.cbFix = sizeof(BMHeader);
    if (!IconInfo.hbmColor ||
        !GpiQueryBitmapInfoHeader(IconInfo.hbmColor, &BMHeader) ||
        BMHeader.cBitCount == 1)
      break;

    // alloc space for the color bitmap's info, including its color table
    uint32_t cbBMInfo = sizeof(BITMAPINFO2) + (sizeof(RGB2) * 255);
    pBMInfo = (PBITMAPINFO2)nsMemory::Alloc(cbBMInfo);
    if (!pBMInfo)
      break;

    // alloc space for the color bitmap data
    uint32_t cbInRow = ALIGNEDBPR(BMHeader.cx, BMHeader.cBitCount);
    uint32_t cbInBuf = cbInRow * BMHeader.cy;
    pInBuf = (uint8_t*)nsMemory::Alloc(cbInBuf);
    if (!pInBuf)
      break;
    memset(pInBuf, 0, cbInBuf);

    // alloc space for the BGRA32 bitmap we're creating
    uint32_t cxOut    = fShrink ? BMHeader.cx / 2 : BMHeader.cx;
    uint32_t cyOut    = fShrink ? BMHeader.cy / 2 : BMHeader.cy;
    uint32_t cbOutBuf = 2 + ALIGNEDBPR(cxOut, 32) * cyOut;
    pOutBuf = (uint8_t*)nsMemory::Alloc(cbOutBuf);
    if (!pOutBuf)
      break;
    memset(pOutBuf, 0, cbOutBuf);

    // create a DC and PS
    DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL};
    hdc = DevOpenDC((HAB)0, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
    if (!hdc)
      break;

    SIZEL sizel = {0,0};
    hps = GpiCreatePS((HAB)0, hdc, &sizel, GPIA_ASSOC | PU_PELS | GPIT_MICRO);
    if (!hps)
      break;

    // get the color bits
    memset(pBMInfo, 0, cbBMInfo);
    *((PBITMAPINFOHEADER2)pBMInfo) = BMHeader;
    GpiSetBitmap(hps, IconInfo.hbmColor);
    if (GpiQueryBitmapBits(hps, 0L, (LONG)BMHeader.cy,
                           (BYTE*)pInBuf, pBMInfo) <= 0)
      break;

    // The first 2 bytes are the width & height of the icon in pixels,
    // the remaining bytes are BGRA32 (B in first byte, A in last)
    uint8_t* outPtr = pOutBuf;
    *outPtr++ = (uint8_t)cxOut;
    *outPtr++ = (uint8_t)cyOut;

    // convert the color bitmap
    pBMInfo->cbImage = cbInBuf;
    ConvertColorBitMap(pInBuf, pBMInfo, outPtr, fShrink);

    // now we need to tack on the alpha data, so jump back to the first
    // pixel in the output buffer
    outPtr = pOutBuf+2;

    // Get the mask info
    BMHeader.cbFix = sizeof(BMHeader);
    if (!GpiQueryBitmapInfoHeader(IconInfo.hbmPointer, &BMHeader))
      break;

    // if the existing input buffer isn't large enough, reallocate it
    cbInRow = ALIGNEDBPR(BMHeader.cx, BMHeader.cBitCount);
    if ((cbInRow * BMHeader.cy) > cbInBuf)  // Need more for mask
    {
      cbInBuf = cbInRow * BMHeader.cy;
      nsMemory::Free(pInBuf);
      pInBuf = (uint8_t*)nsMemory::Alloc(cbInBuf);
      memset(pInBuf, 0, cbInBuf);
    }

    // get the mask/alpha bits
    memset(pBMInfo, 0, cbBMInfo);
    *((PBITMAPINFOHEADER2)pBMInfo) = BMHeader;
    GpiSetBitmap(hps, IconInfo.hbmPointer);
    if (GpiQueryBitmapBits(hps, 0L, (LONG)BMHeader.cy,
                           (BYTE*)pInBuf, pBMInfo) <= 0)
      break;

    // convert the mask/alpha bitmap
    pBMInfo->cbImage = cbInBuf;
    ConvertMaskBitMap(pInBuf, pBMInfo, outPtr, fShrink);

    // create a pipe
    nsCOMPtr<nsIInputStream> inStream;
    nsCOMPtr<nsIOutputStream> outStream;
    rv = NS_NewPipe(getter_AddRefs(inStream), getter_AddRefs(outStream),
                    cbOutBuf, cbOutBuf, nonBlocking);
    if (NS_FAILED(rv))
      break;

    // put our data into the pipe
    uint32_t written;
    rv = outStream->Write(reinterpret_cast<const char*>(pOutBuf),
                          cbOutBuf, &written);
    if (NS_FAILED(rv))
      break;

    // success! so addref the pipe
    NS_ADDREF(*_retval = inStream);
  } while (0);

  // free all the resources we allocated
  if (pOutBuf)
    nsMemory::Free(pOutBuf);
  if (pInBuf)
    nsMemory::Free(pInBuf);
  if (pBMInfo)
    nsMemory::Free(pBMInfo);
  if (hps) {
    GpiAssociate(hps, NULLHANDLE);
    GpiDestroyPS(hps);
  }
  if (hdc)
    DevCloseDC(hdc);
  if (hIcon)
    DestroyIcon(hIcon, fWpsIcon);

  return rv;
}
Пример #30
0
BOOL CreateImages(PLUGINSHARE *pPluginData)
{
    int     i;
    HBITMAP hbmTemp;
    HAB     hab = WinQueryAnchorBlock(HWND_DESKTOP);
    HDC     hdcSrc, hdcDest;
    HPS     hpsSrc, hpsDest;
    SIZEL   slHPS;
    BITMAPINFOHEADER2 bif2Src, bif2Dest;
    POINTL aptl[4];

    if (pPluginData == NULL)
        return (FALSE);

    hbmTemp = SetupBitmapFromFile(HWND_DESKTOP, pPluginData->szImageFile/*, 22*/);

    if (hbmTemp == NULLHANDLE)
        return FALSE;

    memset(&bif2Src, 0, sizeof(bif2Src));
    bif2Src.cbFix = sizeof(bif2Src);
    GpiQueryBitmapInfoHeader(hbmTemp, &bif2Src);
    hdcSrc = DevOpenDC(hab, OD_MEMORY, "*", 0L, (PDEVOPENDATA) NULL, NULLHANDLE);
    slHPS.cx = bif2Src.cx;
    slHPS.cy = bif2Src.cy;
    pPluginData->ulCx=slHPS.cx;
    pPluginData->ulCy=slHPS.cy;

    hpsSrc = GpiCreatePS(hab,
                      hdcSrc,
                      &slHPS,
                      PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);
    GpiSetBitmap(hpsSrc, hbmTemp);

    hdcDest = DevOpenDC(hab, OD_MEMORY, "*", 0L, (PDEVOPENDATA) NULL, NULLHANDLE);


    slHPS.cx = bif2Src.cx / 2;
    slHPS.cy = bif2Src.cy / 5;
    hpsDest = GpiCreatePS(hab,
                      hdcDest,
                      &slHPS,
                      PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC);

    memset(&bif2Dest, 0, sizeof(bif2Dest));
    bif2Dest.cbFix = sizeof(bif2Dest);
    bif2Dest.cx = slHPS.cx;
    bif2Dest.cy = slHPS.cy;
    bif2Dest.cBitCount = 24;
    bif2Dest.cPlanes = 1;

//Close Button
    pPluginData->hbmActiveClose = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmActiveClose);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = 0;
    aptl[2].y = 0;
    aptl[3].x = slHPS.cx;
    aptl[3].y = slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);

//Minimize Button
    pPluginData->hbmActiveMinimize = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmActiveMinimize);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = 0;
    aptl[2].y = slHPS.cy * 1;
    aptl[3].x = aptl[2].x + slHPS.cx;
    aptl[3].y = aptl[2].y + slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);

//Maximize Button
    pPluginData->hbmActiveMaximize = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmActiveMaximize);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = 0;
    aptl[2].y = slHPS.cy * 2;
    aptl[3].x = aptl[2].x + slHPS.cx;
    aptl[3].y = aptl[2].y + slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);

//Restore Button
    pPluginData->hbmActiveRestore = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmActiveRestore);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = 0;
    aptl[2].y = slHPS.cy * 3;
    aptl[3].x = aptl[2].x + slHPS.cx;
    aptl[3].y = aptl[2].y + slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);

//Hide Button
    pPluginData->hbmActiveHide = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmActiveHide);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = 0;
    aptl[2].y = slHPS.cy * 4;
    aptl[3].x = aptl[2].x + slHPS.cx;
    aptl[3].y = aptl[2].y + slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);



    /* Inactive... */

//Close Button
    pPluginData->hbmInactiveClose = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmInactiveClose);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = slHPS.cx ;
    aptl[2].y = 0;
    aptl[3].x = aptl[2].x + slHPS.cx;
    aptl[3].y = aptl[2].y + slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);

//Minimize Button
    pPluginData->hbmInactiveMinimize = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmInactiveMinimize);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = slHPS.cx;
    aptl[2].y = slHPS.cy * 1;
    aptl[3].x = aptl[2].x + slHPS.cx;
    aptl[3].y = aptl[2].y + slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);

//Maximize Button
    pPluginData->hbmInactiveMaximize = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmInactiveMaximize);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = slHPS.cx;
    aptl[2].y = slHPS.cy * 2;
    aptl[3].x = aptl[2].x + slHPS.cx;
    aptl[3].y = aptl[2].y + slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);


//Restore Button
    pPluginData->hbmInactiveRestore = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmInactiveRestore);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = slHPS.cx;
    aptl[2].y = slHPS.cy * 3;
    aptl[3].x = aptl[2].x + slHPS.cx;
    aptl[3].y = aptl[2].y + slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);


//Hide Button
    pPluginData->hbmInactiveHide = GpiCreateBitmap(hpsDest,
                                    &bif2Dest,
                                    0L,
                                    NULL,
                                    NULL);

    GpiSetBitmap(hpsDest, pPluginData->hbmInactiveHide);

    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = slHPS.cx;
    aptl[1].y = slHPS.cy;
    aptl[2].x = slHPS.cx;
    aptl[2].y = slHPS.cy * 4;
    aptl[3].x = aptl[2].x + slHPS.cx;
    aptl[3].y = aptl[2].y + slHPS.cy;
    GpiBitBlt(hpsDest, hpsSrc, 4, aptl, ROP_SRCCOPY, BBO_IGNORE);

   GpiSetBitmap(hpsSrc, NULLHANDLE);

    if (hbmTemp != NULLHANDLE)
        GpiDeleteBitmap(hbmTemp);
    if (hpsSrc != NULLHANDLE)
        GpiDestroyPS(hpsSrc);
    if (hdcSrc != NULLHANDLE)
        DevCloseDC(hdcSrc);


    GpiSetBitmap(hpsDest, NULLHANDLE);
    if (hpsDest != NULLHANDLE)
        GpiDestroyPS(hpsDest);
    if (hdcDest != NULLHANDLE)
        DevCloseDC(hdcDest);

    return TRUE;
}