X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c90c34007a72d942f378e46b77e4f4456ac9c5b1..f5766910b6731eb03e82371416e9778203396ce7:/src/os2/bitmap.cpp?ds=sidebyside diff --git a/src/os2/bitmap.cpp b/src/os2/bitmap.cpp index 8f74051db4..c1bbb3e002 100644 --- a/src/os2/bitmap.cpp +++ b/src/os2/bitmap.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: bitmap.cpp +// Name: src/os2/bitmap.cpp // Purpose: wxBitmap // Author: David Webster // Modified by: @@ -9,13 +9,11 @@ // 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 @@ -24,15 +22,13 @@ #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" // ---------------------------------------------------------------------------- @@ -94,9 +90,7 @@ void wxBitmap::Init() // } // end of wxBitmap::Init -bool wxBitmap::CopyFromIconOrCursor( - const wxGDIImage& rIcon -) +bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& rIcon) { HPOINTER hIcon = (HPOINTER)rIcon.GetHandle(); POINTERINFO SIconInfo; @@ -277,7 +271,7 @@ wxBitmap::wxBitmap( } // end of wxBitmap::wxBitmap wxBitmap::wxBitmap( - void* pData + const void* pData , long lType , int nWidth , int nHeight @@ -386,27 +380,6 @@ bool wxBitmap::Create( return Ok(); } // end of wxBitmap::Create -bool wxBitmap::CreateFromXpm( - const char** ppData -) -{ -#if wxUSE_IMAGE && wxUSE_XPM - Init(); - - wxCHECK_MSG(ppData != NULL, false, wxT("invalid bitmap data")) - - wxXPMDecoder vDecoder; - wxImage vImg = vDecoder.ReadData(ppData); - - wxCHECK_MSG(vImg.Ok(), false, wxT("invalid bitmap data")) - - *this = wxBitmap(vImg); - return true; -#else - return false; -#endif -} // end of wxBitmap::CreateFromXpm - bool wxBitmap::LoadFile(const wxString& filename, long type) { UnRef(); @@ -464,7 +437,7 @@ bool wxBitmap::LoadFile( } // end of wxBitmap::LoadFile bool wxBitmap::Create( - void* pData + const void* pData , long lType , int nWidth , int nHeight @@ -1456,7 +1429,7 @@ bool wxMask::Create( // ---------------------------------------------------------------------------- bool wxBitmapHandler::Create( wxGDIImage* pImage, - void* pData, + const void* pData, long WXUNUSED(lFlags), int nWidth, int nHeight, @@ -1512,7 +1485,7 @@ bool wxBitmapHandler::Save( bool wxBitmapHandler::Create( wxBitmap* WXUNUSED(pBitmap) -, void* WXUNUSED(pData) +, const void* WXUNUSED(pData) , long WXUNUSED(lType) , int WXUNUSED(nWidth) , int WXUNUSED(nHeight) @@ -1624,3 +1597,80 @@ HBITMAP wxInvertMask( 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