/////////////////////////////////////////////////////////////////////////////
-// Name: bitmap.cpp
+// Name: src/os2/bitmap.cpp
// Purpose: wxBitmap
// Author: David Webster
// Modified by:
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
- #pragma implementation "bitmap.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#include "wx/bitmap.h"
+
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/app.h"
#include "wx/palette.h"
#include "wx/dcmemory.h"
- #include "wx/bitmap.h"
#include "wx/icon.h"
+ #include "wx/log.h"
+ #include "wx/image.h"
#endif
#include "wx/os2/private.h"
-#include "wx/log.h"
-//#include "wx/msw/dib.h"
-#include "wx/image.h"
#include "wx/xpmdecod.h"
// ----------------------------------------------------------------------------
//
} // end of wxBitmap::Init
-bool wxBitmap::CopyFromIconOrCursor(
- const wxGDIImage& rIcon
-)
+bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& rIcon)
{
HPOINTER hIcon = (HPOINTER)rIcon.GetHandle();
POINTERINFO SIconInfo;
} // end of wxBitmap::wxBitmap
wxBitmap::wxBitmap(
- void* pData
+ const void* pData
, long lType
, int nWidth
, int nHeight
return Ok();
} // end of wxBitmap::Create
-bool wxBitmap::CreateFromXpm(
- const char** ppData
-)
+bool wxBitmap::LoadFile(const wxString& filename, long type)
{
-#if wxUSE_IMAGE && wxUSE_XPM
- Init();
+ UnRef();
- wxCHECK_MSG(ppData != NULL, false, wxT("invalid bitmap data"))
+ wxBitmapHandler *handler = wxDynamicCast(FindHandler(type), wxBitmapHandler);
- wxXPMDecoder vDecoder;
- wxImage vImg = vDecoder.ReadData(ppData);
+ if ( handler )
+ {
+ m_refData = new wxBitmapRefData;
- wxCHECK_MSG(vImg.Ok(), false, wxT("invalid bitmap data"))
+ return handler->LoadFile(this, filename, type, -1, -1);
+ }
+#if wxUSE_IMAGE
+ else // no bitmap handler found
+ {
+ wxImage image;
+ if ( image.LoadFile( filename, type ) && image.Ok() )
+ {
+ *this = wxBitmap(image);
+
+ return true;
+ }
+ }
+#endif // wxUSE_IMAGE
- *this = wxBitmap(vImg);
- return true;
-#else
return false;
-#endif
-} // end of wxBitmap::CreateFromXpm
+}
bool wxBitmap::LoadFile(
int nId
} // end of wxBitmap::LoadFile
bool wxBitmap::Create(
- void* pData
+ const void* pData
, long lType
, int nWidth
, int nHeight
// ----------------------------------------------------------------------------
bool wxBitmapHandler::Create( wxGDIImage* pImage,
- void* pData,
+ const void* pData,
long WXUNUSED(lFlags),
int nWidth,
int nHeight,
bool wxBitmapHandler::Create(
wxBitmap* WXUNUSED(pBitmap)
-, void* WXUNUSED(pData)
+, const void* WXUNUSED(pData)
, long WXUNUSED(lType)
, int WXUNUSED(nWidth)
, int WXUNUSED(nHeight)
return false;
}
+bool wxBitmapHandler::LoadFile(
+ wxBitmap* WXUNUSED(pBitmap)
+, const wxString& WXUNUSED(rName)
+, long WXUNUSED(lType)
+, int WXUNUSED(nDesiredWidth)
+, int WXUNUSED(nDesiredHeight)
+)
+{
+ return false;
+}
+
bool wxBitmapHandler::SaveFile(
wxBitmap* WXUNUSED(pBitmap)
, const wxString& WXUNUSED(rName)
return hBmpInvMask;
} // end of WxWinGdi_InvertMask
+
+HBITMAP wxFlipBmp( HBITMAP hBmp, int nWidth, int nHeight )
+{
+ wxCHECK_MSG( hBmp, 0, _T("invalid bitmap in wxFlipBmp") );
+
+ //
+ // Get width/height from the bitmap if not given
+ //
+ if (!nWidth || !nHeight)
+ {
+ BITMAPINFOHEADER2 vBmhdr;
+
+ vBmhdr.cbFix = 16;
+ ::GpiQueryBitmapInfoHeader( hBmp,
+ &vBmhdr );
+ nWidth = (int)vBmhdr.cx;
+ nHeight = (int)vBmhdr.cy;
+ }
+
+ BITMAPINFOHEADER2 vBmih;
+ SIZEL vSize = {0, 0};
+ DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
+ HDC hDCSrc = ::DevOpenDC( vHabmain,
+ OD_MEMORY,
+ "*",
+ 5L,
+ (PDEVOPENDATA)&vDop,
+ NULLHANDLE );
+ HDC hDCDst = ::DevOpenDC( vHabmain,
+ OD_MEMORY,
+ "*",
+ 5L,
+ (PDEVOPENDATA)&vDop,
+ NULLHANDLE );
+ HPS hPSSrc = ::GpiCreatePS( vHabmain,
+ hDCSrc,
+ &vSize,
+ PU_PELS | GPIA_ASSOC );
+ HPS hPSDst = ::GpiCreatePS( vHabmain,
+ hDCDst,
+ &vSize,
+ PU_PELS | GPIA_ASSOC );
+ POINTL vPoint[4] = { {0, nHeight},
+ {nWidth, 0},
+ {0, 0},
+ {nWidth, nHeight} };
+
+ memset(&vBmih, '\0', 16);
+ vBmih.cbFix = 16;
+ vBmih.cx = nWidth;
+ vBmih.cy = nHeight;
+ vBmih.cPlanes = 1;
+ vBmih.cBitCount = 24;
+
+ HBITMAP hInvBmp = ::GpiCreateBitmap( hPSDst,
+ &vBmih,
+ 0L,
+ NULL,
+ NULL );
+
+ ::GpiSetBitmap(hPSSrc, (HBITMAP) hBmp);
+ ::GpiSetBitmap(hPSDst, (HBITMAP) hInvBmp);
+
+ ::GpiBitBlt( hPSDst,
+ hPSSrc,
+ 4L,
+ vPoint,
+ ROP_SRCCOPY,
+ BBO_IGNORE );
+
+ ::GpiDestroyPS(hPSSrc);
+ ::GpiDestroyPS(hPSDst);
+ ::DevCloseDC(hDCSrc);
+ ::DevCloseDC(hDCDst);
+
+ return hInvBmp;
+} // end of wxFlipBmp