--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: xpmhand.h
+// Purpose: XPM bitmap handler
+// Author: Julian Smart
+// Modified by:
+// Created: 04/01/98
+// RCS-ID: $Id$
+// Copyright: (c) Julian Smart
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma interface "xpmhand.h"
+#endif
+
+#ifndef _WX_XPMHAND_H_
+#define _WX_XPMHAND_H_
+
+class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler
+{
+ DECLARE_DYNAMIC_CLASS(wxXPMFileHandler)
+public:
+ inline wxXPMFileHandler(void)
+ {
+ m_sName = "XPM bitmap file";
+ m_sExtension = "xpm";
+ m_lType = wxBITMAP_TYPE_XPM;
+ };
+
+ virtual bool LoadFile( wxBitmap* pBitmap
+ ,const wxString& rsName
+ ,long lFlags
+ ,int nDesiredWidth = -1
+ ,int nDesiredHeight = -1
+ );
+ virtual bool SaveFile( wxBitmap* pBitmap
+ ,const wxString& rsName
+ ,int nType
+ ,const wxPalette* pPalette = NULL
+ );
+}; // end of CLASS wxWPMFileHandler
+
+class WXDLLEXPORT wxXPMDataHandler: public wxBitmapHandler
+{
+ DECLARE_DYNAMIC_CLASS(wxXPMDataHandler)
+public:
+ inline wxXPMDataHandler(void)
+ {
+ m_sName = "XPM bitmap data";
+ m_sExtension = "xpm";
+ m_lType = wxBITMAP_TYPE_XPM_DATA;
+ };
+ virtual bool Create( wxBitmap* pBitmap
+ ,void* pData
+ ,long lFlags
+ ,int lWidth
+ ,int lHeight
+ ,int lDepth = 1
+ );
+}; // end of wxXPMDataHandler
+
+#endif
+ // _WX_XPMHAND_H_
+
return(FALSE);
}
+// ----------------------------------------------------------------------------
+// Utility functions
+// ----------------------------------------------------------------------------
+HBITMAP wxInvertMask(
+ HBITMAP hBmpMask
+, int nWidth
+, int nHeight
+)
+{
+ HBITMAP hBmpInvMask = 0;
+
+ wxCHECK_MSG( hBmpMask, 0, _T("invalid bitmap in wxInvertMask") );
+
+ //
+ // Get width/height from the bitmap if not given
+ //
+ if (!nWidth || !nHeight)
+ {
+ BITMAPINFOHEADER2 vBmhdr;
+
+ ::GpiQueryBitmapInfoHeader( hBmpMask
+ ,&vBmhdr
+ );
+ nWidth = (int)vBmhdr.cx;
+ nHeight = (int)vBmhdr.cyt;
+ }
+
+ BITMAPINFOHEADER2 vBmih;
+ SIZEL vSize = {0, 0};
+ DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
+ HDC hDCSrc = ::DevOpenDC(ghAb, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
+ HDC hDCDst = ::DevOpenDC(ghAb, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
+ HPS hPSSrc = ::GpiCreatePS(ghAb, hDCSrc, &vSize, PU_PELS | GPIA_ASSOC);
+ HPS hPSDst = ::GpiCreatePS(ghAb, hDCDst, &vSize, PU_PELS | GPIA_ASSOC);
+ POINTL vPoint[4] = { 0 ,0, rBitmap.GetWidth(), rBitmap.GetHeight(),
+ 0, 0, rBitmap.GetWidth(), rBitmap.GetHeight()
+ };
+
+ memset(&vBmih, NULLC, sizeof(BITMAPINFOHEADER2));
+ vBmih.cbFix = sizeof(BITMAPINFOHEADER2);
+ vBmih.cx = lWidth;
+ vBmih.cy = lHeight;
+ vBmih.cPlanes = 1;
+ vBmih.cBitCount = 1;
+
+ hBmpInvMask = ::GpiCreateBitmap( hPSDst
+ ,&vBmih
+ ,0L
+ ,NULL
+ ,NULL
+ );
+
+ ::GpiSetBitmap(hPSSrc, (HBITMAP) hBmpMask);
+ ::GpiSetBitmap(hPSDst, (HBITMAP) hBmpInvMask);
+
+ ::GpiBitBlt( hPSDst
+ ,hPSSrc
+ ,4L
+ ,&vPoint
+ ,ROP_SRCCOPY
+ ,BBO_IGNORE
+ );
+
+ ::GpiDestroyPS(hPSSrc);
+ ::GpiDestroyPS(hPSDst);
+ ::DevCloseDC(hDCSrc);
+ ::DevCloseDC(hDCDtl);
+
+ return hBmpInvMask;
+} // end of WxWinGdi_InvertMask
pRefData->m_nHeight = vBm.cy;
pRefData->m_nDepth = vBm.cPlanes * vBm.cBitCount;
pRefData->m_nNumColors = rXpmAttr.npixels;
-#if 0
+
if (pXmask)
{
wxMask* pMask = new wxMask();
));
pBitmap->SetMask(pMask);
}
-#endif
} // end of XpmToBitmap
IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler)
,&vXpmAttr
);
::GpiDestroyPS(hPS);
+ ::DevCloseDC(hDC);
if (nErrorStatus == XpmSuccess)
{
XpmToBitmap( pBitmap
,(XpmAttributes *) NULL
);
::GpiDestroyPS(hPS);
+ ::DevCloseDC(hDC);
return (nErrorStatus == XpmSuccess);
}
return FALSE;
if (hPS)
{
vXpmAttr.valuemask = XpmReturnInfos | XpmColorTable;
+
int nErrorStatus = XpmCreateImageFromData( &hPS
,(char **)pData
,&pXimage
,&pXmask
,&vXpmAttr
);
- GpiDestroyPS(hPS);
+ ::GpiDestroyPS(hPS);
+ ::DevCloseDC(hDC);
if (nErrorStatus == XpmSuccess)
{
XpmToBitmap( pBitmap