Lots of image/bitmap processing updates.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2002-04-29 04:00:57 +00:00
parent b3d3ebae71
commit ba3e10c9f4
4 changed files with 250 additions and 65 deletions

View File

@@ -227,6 +227,8 @@ wxBitmap::wxBitmap(
pzData = (char *)zBits; // const_cast is harmless
}
if (nDepth > 24)
nDepth = 24; // MAX supported in PM
memset(&vHeader, '\0', 16);
vHeader.cbFix = 16;
vHeader.cx = (USHORT)nWidth;
@@ -346,6 +348,9 @@ bool wxBitmap::Create(
hDCScreen = ::GpiQueryDevice(hPSScreen);
::DevQueryCaps(hDCScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitCount);
if (lBitCount > 24)
lBitCount = 24;
memset(&vHeader, '\0', 16);
vHeader.cbFix = 16;
vHeader.cx = nW;
@@ -563,6 +568,8 @@ bool wxBitmap::CreateFromImage (
//
BITMAPINFOHEADER2 vHeader;
BITMAPINFO2 vInfo;
LONG alFormats[24]; // Max formats OS/2 PM supports
ULONG ulBitcount;
//
// Fill in the DIB header
@@ -574,12 +581,6 @@ bool wxBitmap::CreateFromImage (
vHeader.cPlanes = 1L;
vHeader.cBitCount = 24;
memset(&vInfo, '\0', 16);
vInfo.cbFix = 16;
vInfo.cx = (ULONG)nWidth;
vInfo.cy = (ULONG)nHeight;
vInfo.cPlanes = 1L;
vInfo.cBitCount = 24;
//
// Memory for DIB data
//
@@ -605,6 +606,17 @@ bool wxBitmap::CreateFromImage (
HBITMAP hBmp;
HBITMAP hBmpOld;
::GpiQueryDeviceBitmapFormats(hPS, 24, alFormats);
ulBitcount = alFormats[1]; // the best one for the device
if (ulBitcount > 24)
ulBitcount = 24; // MAX bits supported by PM
memset(&vInfo, '\0', 16);
vInfo.cbFix = 16;
vInfo.cx = (ULONG)nWidth;
vInfo.cy = (ULONG)nHeight;
vInfo.cPlanes = 1;
vInfo.cBitCount = ulBitcount;
hBmp = ::GpiCreateBitmap( hPS
,&vHeader
,0L
@@ -661,7 +673,6 @@ bool wxBitmap::CreateFromImage (
// Have to do something similar to WIN32's StretchDIBits, use GpiBitBlt
// in combination with setting the bits into the selected bitmap
//
vInfo.cBitCount = 16;
if ((lScans = ::GpiSetBitmapBits( hPS
,0 // Start at the bottom
,(LONG)nHeight // One line per scan
@@ -676,25 +687,6 @@ bool wxBitmap::CreateFromImage (
sError = wxPMErrorToStr(vError);
}
//
// for debugging----
//
LONG alFormats[24];
::GpiQueryDeviceBitmapFormats(hPS, 24, alFormats);
if ((lScans = ::GpiQueryBitmapBits( hPS
,0L
,(LONG)nHeight
,(PBYTE)pucBits
,&vInfo
)) == GPI_ALTERROR)
{
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
hPSScreen = ::GpiCreatePS( vHabmain
,hDCScreen
,&vSize
@@ -827,6 +819,7 @@ if ((lScans = ::GpiQueryBitmapBits( hPS
//
::GpiSetBitmap(hPS, NULLHANDLE);
::GpiDestroyPS(hPS);
::DevCloseDC(hDCScreen);
::DevCloseDC(hDC);
free(pucBits);
return TRUE;
@@ -862,7 +855,13 @@ wxImage wxBitmap::ConvertToImage() const
DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
SIZEL vSizlPage = {0,0};
HDC hDCMem;
LONG alFormats[24]; // 24 is MAX formats supported
ULONG ulBitcount;
::GpiQueryDeviceBitmapFormats(hPS, 24, alFormats);
ulBitcount = alFormats[1]; // the best one
if (ulBitcount > 24) // PM supports a max of 24
ulBitcount = 24;
vImage.Create( nWidth
,nHeight
);
@@ -895,7 +894,7 @@ wxImage wxBitmap::ConvertToImage() const
vDIBInfo.cx = nWidth;
vDIBInfo.cy = nHeight;
vDIBInfo.cPlanes = 1;
vDIBInfo.cBitCount = 24;
vDIBInfo.cBitCount = ulBitcount;
lpBits = (unsigned char *)malloc(nBytePerLine * nHeight);
if (!lpBits)