More image processing updates

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2002-04-30 22:31:01 +00:00
parent 2d5855f6e4
commit 52315bc3bb
6 changed files with 354 additions and 259 deletions

View File

@@ -568,8 +568,6 @@ bool wxBitmap::CreateFromImage (
// //
BITMAPINFOHEADER2 vHeader; BITMAPINFOHEADER2 vHeader;
BITMAPINFO2 vInfo; BITMAPINFO2 vInfo;
LONG alFormats[24]; // Max formats OS/2 PM supports
ULONG ulBitcount;
// //
// Fill in the DIB header // Fill in the DIB header
@@ -592,6 +590,7 @@ bool wxBitmap::CreateFromImage (
wxFAIL_MSG(wxT("could not allocate memory for DIB")); wxFAIL_MSG(wxT("could not allocate memory for DIB"));
return FALSE; return FALSE;
} }
memset(pucBits, '\0', (nBytePerLine * nHeight));
// //
// Create and set the device-dependent bitmap // Create and set the device-dependent bitmap
@@ -606,16 +605,12 @@ bool wxBitmap::CreateFromImage (
HBITMAP hBmp; HBITMAP hBmp;
HBITMAP hBmpOld; 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); memset(&vInfo, '\0', 16);
vInfo.cbFix = 16; vInfo.cbFix = 16;
vInfo.cx = (ULONG)nWidth; vInfo.cx = (ULONG)nWidth;
vInfo.cy = (ULONG)nHeight; vInfo.cy = (ULONG)nHeight;
vInfo.cPlanes = 1; vInfo.cPlanes = 1;
vInfo.cBitCount = ulBitcount; vInfo.cBitCount = 24; // Set to desired count going in
hBmp = ::GpiCreateBitmap( hPS hBmp = ::GpiCreateBitmap( hPS
,&vHeader ,&vHeader
@@ -686,6 +681,9 @@ bool wxBitmap::CreateFromImage (
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError); sError = wxPMErrorToStr(vError);
} }
//
// Debug stuff
//
hPSScreen = ::GpiCreatePS( vHabmain hPSScreen = ::GpiCreatePS( vHabmain
,hDCScreen ,hDCScreen
@@ -855,13 +853,7 @@ wxImage wxBitmap::ConvertToImage() const
DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
SIZEL vSizlPage = {0,0}; SIZEL vSizlPage = {0,0};
HDC hDCMem; 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 vImage.Create( nWidth
,nHeight ,nHeight
); );
@@ -894,7 +886,7 @@ wxImage wxBitmap::ConvertToImage() const
vDIBInfo.cx = nWidth; vDIBInfo.cx = nWidth;
vDIBInfo.cy = nHeight; vDIBInfo.cy = nHeight;
vDIBInfo.cPlanes = 1; vDIBInfo.cPlanes = 1;
vDIBInfo.cBitCount = ulBitcount; vDIBInfo.cBitCount = 24;
lpBits = (unsigned char *)malloc(nBytePerLine * nHeight); lpBits = (unsigned char *)malloc(nBytePerLine * nHeight);
if (!lpBits) if (!lpBits)
@@ -903,6 +895,8 @@ wxImage wxBitmap::ConvertToImage() const
free(pData); free(pData);
return wxNullImage; return wxNullImage;
} }
memset(lpBits, '\0', (nBytePerLine * nHeight));
hBitmap = (HBITMAP)GetHBITMAP();
// //
// May already be selected into a PS // May already be selected into a PS
@@ -925,7 +919,6 @@ wxImage wxBitmap::ConvertToImage() const
,&vSizlPage ,&vSizlPage
,PU_PELS | GPIA_ASSOC ,PU_PELS | GPIA_ASSOC
); );
hBitmap = (HBITMAP)GetHBITMAP();
if ((hOldBitmap = ::GpiSetBitmap(hPSMem, hBitmap)) == HBM_ERROR) if ((hOldBitmap = ::GpiSetBitmap(hPSMem, hBitmap)) == HBM_ERROR)
{ {
ERRORID vError; ERRORID vError;

View File

@@ -1212,13 +1212,7 @@ void wxDC::DoDrawBitmap(
if (!IsKindOf(CLASSINFO(wxPrinterDC))) if (!IsKindOf(CLASSINFO(wxPrinterDC)))
{ {
HBITMAP hBitmap = (HBITMAP)rBmp.GetHBITMAP(); HBITMAP hBitmap = (HBITMAP)rBmp.GetHBITMAP();
wxBitmap vNewBitmap( rBmp.GetWidth() HBITMAP hBitmapOld;
,rBmp.GetHeight()
,rBmp.GetDepth()
);
HBITMAP hBitmapOld = ::GpiSetBitmap((HPS)GetHPS(), vNewBitmap.GetHBITMAP());
LONG lOldTextground = ::GpiQueryColor((HPS)GetHPS());
LONG lOldBackground = ::GpiQueryBackColor((HPS)GetHPS());
vY = OS2Y(vY,rBmp.GetHeight()); vY = OS2Y(vY,rBmp.GetHeight());
@@ -1230,124 +1224,237 @@ void wxDC::DoDrawBitmap(
,0, 0 ,0, 0
,rBmp.GetWidth(), rBmp.GetHeight() ,rBmp.GetWidth(), rBmp.GetHeight()
}; };
if (m_textForegroundColour.Ok())
{
::GpiSetColor( (HPS)GetHPS()
,m_textForegroundColour.GetPixel()
);
}
if (m_textBackgroundColour.Ok())
{
::GpiSetBackColor( (HPS)GetHPS()
,m_textBackgroundColour.GetPixel()
);
}
if (bUseMask) if (bUseMask)
{ {
wxMask* pMask = rBmp.GetMask(); wxMask* pMask = rBmp.GetMask();
HPS hPS;
HDC hDC;
if (!IsKindOf(CLASSINFO(wxMemoryDC)))
{
DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
SIZEL vSize = {0, 0};
hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
hPS = ::GpiCreatePS(vHabmain, hDC, &vSize, PU_PELS | GPIA_ASSOC);
}
else
hPS = m_hPS;
if (pMask) if (pMask)
{ {
BITMAPINFOHEADER2 vHeader; //
BITMAPINFO2 vInfo; // Need to imitate ::MaskBlt in windows.
int nBytesPerLine = rBmp.GetWidth() * 3; // 1) Extract the bits from from the bitmap.
unsigned char* pucData; // 2) Extract the bits from the mask
LONG lScans = 0L; // 3) Using the mask bits do the following:
LONG alFormats[24]; // Max formats OS/2 PM supports // A) If the mask byte is 00 leave the bitmap byte alone
ULONG ulBitcount; // B) If the mask byte is FF copy the screen color into
HBITMAP hMask = (HBITMAP)pMask->GetMaskBitmap(); // bitmap byte
POINTL vPointMask[4] = { 0, 0, rBmp.GetWidth(), rBmp.GetHeight() // 4) Create a new bitmap and set its bits to the above result
,0, 0, rBmp.GetWidth(), rBmp.GetHeight() // 5) Blit this to the screen PS
}; //
HBITMAP hMask = (HBITMAP)pMask->GetMaskBitmap();
HBITMAP hOldBitmap = NULLHANDLE;
HBITMAP hNewBitmap = NULLHANDLE;
unsigned char* pucBits; // buffer that will contain the bitmap data
unsigned char* pucBitsMask; // buffer that will contain the mask data
unsigned char* pucData; // pointer to use to traverse bitmap data
unsigned char* pucDataMask; // pointer to use to traverse mask data
LONG lHits;
ERRORID vError;
wxString sError;
::GpiSetBitmap(hPS, hMask); //
// The usual Memory context creation stuff
//
DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
SIZEL vSize = {0, 0};
HDC hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
HPS hPS = ::GpiCreatePS(vHabmain, hDC, &vSize, PU_PELS | GPIA_ASSOC);
::GpiQueryDeviceBitmapFormats(hPS, 24, alFormats); //
ulBitcount = alFormats[1]; // the best one // The usual bitmap header stuff
if (ulBitcount > 24) // PM supports a max of 24 //
ulBitcount = 24; BITMAPINFOHEADER2 vHeader;
BITMAPINFO2 vInfo;
vInfo.cbFix = 16; memset(&vHeader, '\0', 16);
vInfo.cx = rBmp.GetWidth(); vHeader.cbFix = 16;
vInfo.cy = rBmp.GetHeight(); vHeader.cx = (ULONG)rBmp.GetWidth();
vInfo.cPlanes = 1; vHeader.cy = (ULONG)rBmp.GetHeight();
vInfo.cBitCount = ulBitcount; vHeader.cPlanes = 1L;
pucData = (unsigned char*)malloc(nBytesPerLine * rBmp.GetHeight()); vHeader.cBitCount = 24;
memset(&vInfo, '\0', 16);
vInfo.cbFix = 16;
vInfo.cx = (ULONG)rBmp.GetWidth();
vInfo.cy = (ULONG)rBmp.GetHeight();
vInfo.cPlanes = 1;
vInfo.cBitCount = 24; // Set to desired count going in
//
// Create the buffers for data....all wxBitmaps are 24 bit internally
//
int nBytesPerLine = rBmp.GetWidth() * 3;
int nSizeDWORD = sizeof(DWORD);
int nLineBoundary = nBytesPerLine % nSizeDWORD;
int nPadding = 0;
int i;
int j;
LONG lScans = 0L;
LONG lColor = 0L;
//
// Need to get a background color for mask blitting
//
if (IsKindOf(CLASSINFO(wxPaintDC)))
{
wxPaintDC* pPaintDC = wxDynamicCast(this, wxPaintDC);
lColor = pPaintDC->m_pCanvas->GetBackgroundColour().GetPixel();
}
else if (GetBrush() != wxNullBrush)
lColor = GetBrush().GetColour().GetPixel();
else
lColor = m_textBackgroundColour.GetPixel();
//
// Bitmap must be ina double-word alligned address so we may
// have some padding to worry about
//
if (nLineBoundary > 0)
{
nPadding = nSizeDWORD - nLineBoundary;
nBytesPerLine += nPadding;
}
pucBits = (unsigned char *)malloc(nBytesPerLine * rBmp.GetHeight());
pucBitsMask = (unsigned char *)malloc(nBytesPerLine * rBmp.GetHeight());
memset(pucBits, '\0', (nBytesPerLine * rBmp.GetHeight()));
memset(pucBitsMask, '\0', (nBytesPerLine * rBmp.GetHeight()));
//
// Extract the bitmap and mask data
//
if ((hOldBitmap = ::GpiSetBitmap(hPS, hBitmap)) == HBM_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
if ((lScans = ::GpiQueryBitmapBits( hPS if ((lScans = ::GpiQueryBitmapBits( hPS
,0L ,0L
,(LONG)rBmp.GetHeight() ,(LONG)rBmp.GetHeight()
,(PBYTE)pucData ,(PBYTE)pucBits
,&vInfo ,&vInfo
)) == GPI_ALTERROR) )) == GPI_ALTERROR)
{ {
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError); sError = wxPMErrorToStr(vError);
} }
if ((hBitmapOld = ::GpiSetBitmap(hPS, (HBITMAP)vNewBitmap.GetHBITMAP())) == HBM_ERROR) if ((hOldBitmap = ::GpiSetBitmap(hPS, hMask)) == HBM_ERROR)
{ {
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError); sError = wxPMErrorToStr(vError);
} }
if ((lScans = ::GpiSetBitmapBits( hPS if ((lScans = ::GpiQueryBitmapBits( hPS
,0 ,0L
,(LONG)rBmp.GetHeight() ,(LONG)rBmp.GetHeight()
,(PBYTE)pucData ,(PBYTE)pucBitsMask
,&vInfo ,&vInfo
)) == GPI_ALTERROR) )) == GPI_ALTERROR)
{ {
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError); sError = wxPMErrorToStr(vError);
} }
if ((hBitmapOld = ::GpiSetBitmap(hPS, NULLHANDLE)) == HBM_ERROR)
//
// Now set the bytes(bits) according to the mask values
// 3 bytes per pel...must handle one at a time
//
pucData = pucBits;
pucDataMask = pucBitsMask;
for (i = 0; i < rBmp.GetHeight(); i++)
{ {
ERRORID vError; for (j = 0; j < rBmp.GetWidth(); j++)
wxString sError; {
// Byte 1
if (*pucDataMask == 0x00) // leave bitmap byte alone
pucData++;
else
{
*pucData = (unsigned char)lColor;
pucData++;
}
// Byte 2
if (*(pucDataMask + 1) == 0x00) // leave bitmap byte alone
pucData++;
else
{
*pucData = (unsigned char)lColor >> 8;
pucData++;
}
vError = ::WinGetLastError(vHabmain); // Byte 3
sError = wxPMErrorToStr(vError); if (*(pucDataMask + 2) == 0x00) // leave bitmap byte alone
pucData++;
else
{
*pucData = (unsigned char)lColor >> 16;
pucData++;
}
pucDataMask += 3;
}
for (j = 0; j < nPadding; j++)
{
pucData++;
pucDataMask++;
}
} }
if ((hBitmapOld = ::GpiSetBitmap((HPS)GetHPS(), vNewBitmap.GetHBITMAP())) == HBM_ERROR)
//
// Create a new bitmap
//
if ((hNewBitmap = ::GpiCreateBitmap( hPS
,&vHeader
,CBM_INIT
,(PBYTE)pucBits
,&vInfo
)) == GPI_ERROR)
{ {
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError); sError = wxPMErrorToStr(vError);
} }
::GpiWCBitBlt( (HPS)GetHPS()
,hBitmap //
,4 // Now blit it to the screen PS
,vPoint //
,ROP_SRCAND if ((lHits = ::GpiWCBitBlt( (HPS)GetHPS()
,BBO_IGNORE ,hNewBitmap
); ,4
,vPoint
,ROP_SRCCOPY
,BBO_IGNORE
)) == GPI_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
//
// Clean up
//
free(pucBits);
free(pucBitsMask);
::GpiSetBitmap(hPS, NULLHANDLE);
::GpiDestroyPS(hPS);
::DevCloseDC(hDC);
} }
} }
else else
{ {
LONG lOldTextground = ::GpiQueryColor((HPS)GetHPS());
LONG lOldBackground = ::GpiQueryBackColor((HPS)GetHPS());
if (m_textForegroundColour.Ok())
{
::GpiSetColor( (HPS)GetHPS()
,m_textForegroundColour.GetPixel()
);
}
if (m_textBackgroundColour.Ok())
{
::GpiSetBackColor( (HPS)GetHPS()
,m_textBackgroundColour.GetPixel()
);
}
::GpiWCBitBlt( (HPS)GetHPS() ::GpiWCBitBlt( (HPS)GetHPS()
,hBitmap ,hBitmap
,4 ,4
@@ -1355,10 +1462,10 @@ void wxDC::DoDrawBitmap(
,ROP_SRCCOPY ,ROP_SRCCOPY
,BBO_IGNORE ,BBO_IGNORE
); );
::GpiSetBitmap((HPS)GetHPS(), hBitmapOld);
::GpiSetColor((HPS)GetHPS(), lOldTextground);
::GpiSetBackColor((HPS)GetHPS(), lOldBackground);
} }
::GpiSetBitmap((HPS)GetHPS(), hBitmapOld);
::GpiSetColor((HPS)GetHPS(), lOldTextground);
::GpiSetBackColor((HPS)GetHPS(), lOldBackground);
} }
} // end of wxDC::DoDrawBitmap } // end of wxDC::DoDrawBitmap

View File

@@ -319,7 +319,7 @@ wxPaintDC::wxPaintDC(
{ {
HPS hPS; HPS hPS;
m_hDC = (WXHDC)::WinOpenWindowDC(GetWinHwnd(m_pCanvas)); m_hDC = ::WinOpenWindowDC(GetWinHwnd(m_pCanvas));
hPS = ::WinBeginPaint( GetWinHwnd(m_pCanvas) hPS = ::WinBeginPaint( GetWinHwnd(m_pCanvas)
,NULLHANDLE ,NULLHANDLE
,&g_paintStruct ,&g_paintStruct

View File

@@ -24,6 +24,12 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
extern void wxLoadBitmapWithData( HPS hPS
,HBITMAP hBitmap
,int nWidth
,int nHeight
);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Memory DC // Memory DC
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -191,77 +197,11 @@ void wxMemoryDC::DoDrawRectangle(
{ {
wxDC::DoDrawRectangle(vX, vY, vWidth, vHeight); wxDC::DoDrawRectangle(vX, vY, vWidth, vHeight);
// wxLoadBitmapWithData( m_hPS
// Debug testing: ,(HBITMAP)m_vSelectedBitmap.GetHBITMAP()
// ,m_vSelectedBitmap.GetWidth()
if (m_vSelectedBitmap.GetHBITMAP() != NULLHANDLE) ,m_vSelectedBitmap.GetHeight()
{ );
BITMAPINFOHEADER2 vHeader;
BITMAPINFO2 vInfo;
vHeader.cbFix = 16L;
if (::GpiQueryBitmapInfoHeader(m_vSelectedBitmap.GetHBITMAP(), &vHeader))
{
unsigned char* pucData = NULL;
unsigned char* pucBits;
int nBytesPerLine = m_vSelectedBitmap.GetWidth() * 3;
LONG lScans = 0L;
POINTL vPoint;
LONG lColor;
LONG alFormats[24]; // Max formats OS/2 PM supports
ULONG ulBitcount;
::GpiQueryDeviceBitmapFormats(m_hPS, 24, alFormats);
ulBitcount = alFormats[1]; // the best one for the device
if (ulBitcount > 24)
ulBitcount = 24; // MAX bits supported by PM
vInfo.cbFix = 16;
vInfo.cx = vHeader.cx;
vInfo.cy = vHeader.cy;
vInfo.cPlanes = vHeader.cPlanes;
vInfo.cBitCount = ulBitcount;
pucData = (unsigned char*)malloc(nBytesPerLine * m_vSelectedBitmap.GetHeight());
if ((lScans = ::GpiQueryBitmapBits( m_hPS
,0L
,(LONG)m_vSelectedBitmap.GetHeight()
,(PBYTE)pucData
,&vInfo
)) == GPI_ALTERROR)
{
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
pucBits = pucData;
for (int i = 0; i < m_vSelectedBitmap.GetHeight(); i++)
{
for (int j = 0; j < m_vSelectedBitmap.GetWidth(); j++)
{
vPoint.x = j; vPoint.y = i;
lColor = ::GpiQueryPel(m_hPS, &vPoint);
*(pucBits++) = (unsigned char)lColor;
*(pucBits++) = (unsigned char)(lColor >> 8);
*(pucBits++) = (unsigned char)(lColor >> 16);
}
}
if ((lScans = ::GpiSetBitmapBits( m_hPS
,0
,(LONG)m_vSelectedBitmap.GetHeight()
,(PBYTE)pucData
,&vInfo
)) == GPI_ALTERROR)
{
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
free(pucData);
}
}
} // end of wxMemoryDC::DoDrawRectangle } // end of wxMemoryDC::DoDrawRectangle
void wxMemoryDC::DoDrawRoundedRectangle( void wxMemoryDC::DoDrawRoundedRectangle(
@@ -274,76 +214,95 @@ void wxMemoryDC::DoDrawRoundedRectangle(
{ {
wxDC::DoDrawRoundedRectangle(vX, vY, vWidth, vHeight, dRadius); wxDC::DoDrawRoundedRectangle(vX, vY, vWidth, vHeight, dRadius);
// wxLoadBitmapWithData( m_hPS
// Debug testing: ,(HBITMAP)m_vSelectedBitmap.GetHBITMAP()
// ,m_vSelectedBitmap.GetWidth()
if (m_vSelectedBitmap.GetHBITMAP() != NULLHANDLE) ,m_vSelectedBitmap.GetHeight()
{ );
BITMAPINFOHEADER2 vHeader; } // end of wxMemoryDC::DoDrawRoundedRectangle
BITMAPINFO2 vInfo;
vHeader.cbFix = 16L; void wxMemoryDC::DoDrawText(
if (::GpiQueryBitmapInfoHeader(m_vSelectedBitmap.GetHBITMAP(), &vHeader)) const wxString& rsText
{ , wxCoord vX
unsigned char* pucData = NULL; , wxCoord vY
unsigned char* pucBits; )
int nBytesPerLine = m_vSelectedBitmap.GetWidth() * 3; {
LONG lScans = 0L; wxDC::DoDrawText(rsText, vX, vY);
POINTL vPoint;
LONG lColor;
LONG alFormats[24]; // Max formats OS/2 PM supports
ULONG ulBitcount;
::GpiQueryDeviceBitmapFormats(m_hPS, 24, alFormats); wxLoadBitmapWithData( m_hPS
ulBitcount = alFormats[1]; // the best one for the device ,(HBITMAP)m_vSelectedBitmap.GetHBITMAP()
if (ulBitcount > 24) ,m_vSelectedBitmap.GetWidth()
ulBitcount = 24; // MAX bits supported by PM ,m_vSelectedBitmap.GetHeight()
vInfo.cbFix = 16; );
vInfo.cx = vHeader.cx;
vInfo.cy = vHeader.cy;
vInfo.cPlanes = vHeader.cPlanes;
vInfo.cBitCount = ulBitcount;
pucData = (unsigned char*)malloc(nBytesPerLine * m_vSelectedBitmap.GetHeight());
if ((lScans = ::GpiQueryBitmapBits( m_hPS
,0L
,(LONG)m_vSelectedBitmap.GetHeight()
,(PBYTE)pucData
,&vInfo
)) == GPI_ALTERROR)
{
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
pucBits = pucData;
for (int i = 0; i < m_vSelectedBitmap.GetHeight(); i++)
{
for (int j = 0; j < m_vSelectedBitmap.GetWidth(); j++)
{
vPoint.x = j; vPoint.y = i;
lColor = ::GpiQueryPel(m_hPS, &vPoint);
*(pucBits++) = (unsigned char)lColor;
*(pucBits++) = (unsigned char)(lColor >> 8);
*(pucBits++) = (unsigned char)(lColor >> 16);
}
}
if ((lScans = ::GpiSetBitmapBits( m_hPS
,0
,(LONG)m_vSelectedBitmap.GetHeight()
,(PBYTE)pucData
,&vInfo
)) == GPI_ALTERROR)
{
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
free(pucData);
}
}
} // end of wxMemoryDC::DoDrawRectangle } // end of wxMemoryDC::DoDrawRectangle
void wxMemoryDC::DoDrawLine(
wxCoord vX1
, wxCoord vY1
, wxCoord vX2
, wxCoord vY2
)
{
wxDC::DoDrawLine(vX1, vY1, vX2, vY2);
wxLoadBitmapWithData( m_hPS
,(HBITMAP)m_vSelectedBitmap.GetHBITMAP()
,m_vSelectedBitmap.GetWidth()
,m_vSelectedBitmap.GetHeight()
);
} // end of wxMemoryDC::DoDrawRoundedRectangle
void wxLoadBitmapWithData(
HPS hPS
, HBITMAP hBitmap
, int nWidth
, int nHeight
)
{
BITMAPINFOHEADER2 vHeader;
BITMAPINFO2 vInfo;
vHeader.cbFix = 16L;
if (::GpiQueryBitmapInfoHeader(hBitmap, &vHeader))
{
unsigned char* pucData = NULL;
unsigned char* pucBits;
int nBytesPerLine = nWidth * 3;
LONG lScans = 0L;
POINTL vPoint;
LONG lColor;
vInfo.cbFix = 16;
vInfo.cx = vHeader.cx;
vInfo.cy = vHeader.cy;
vInfo.cPlanes = vHeader.cPlanes;
vInfo.cBitCount = 24;
pucData = (unsigned char*)malloc(nBytesPerLine * nHeight);
pucBits = pucData;
for (int i = 0; i < nHeight; i++)
{
for (int j = 0; j < nWidth; j++)
{
vPoint.x = j; vPoint.y = i;
lColor = ::GpiQueryPel(hPS, &vPoint);
*(pucBits++) = (unsigned char)lColor;
*(pucBits++) = (unsigned char)(lColor >> 8);
*(pucBits++) = (unsigned char)(lColor >> 16);
}
}
if ((lScans = ::GpiSetBitmapBits( hPS
,0
,(LONG)nHeight
,(PBYTE)pucData
,&vInfo
)) == GPI_ALTERROR)
{
ERRORID vError;
wxString sError;
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
free(pucData);
}
}

View File

@@ -101,6 +101,10 @@ void wxIcon::CopyFromBitmap(
) )
{ {
wxMask* pMask = rBmp.GetMask(); wxMask* pMask = rBmp.GetMask();
HBITMAP hOldBitmap = NULLHANDLE;
ERRORID vError;
wxString sError;
LONG lHits;
if (!pMask) if (!pMask)
{ {
@@ -117,6 +121,7 @@ void wxIcon::CopyFromBitmap(
memset(&vIconInfo, '\0', sizeof(POINTERINFO)); memset(&vIconInfo, '\0', sizeof(POINTERINFO));
vIconInfo.fPointer = FALSE; // we want an icon, not a pointer vIconInfo.fPointer = FALSE; // we want an icon, not a pointer
vIconInfo.hbmPointer = (HBITMAP) pMask->GetMaskBitmap();
vIconInfo.hbmColor = GetHbitmapOf(rBmp); vIconInfo.hbmColor = GetHbitmapOf(rBmp);
SIZEL vSize = {0, 0}; SIZEL vSize = {0, 0};
@@ -128,15 +133,38 @@ void wxIcon::CopyFromBitmap(
POINTL vPoint[4] = { 0, 0, rBmp.GetWidth(), rBmp.GetHeight(), POINTL vPoint[4] = { 0, 0, rBmp.GetWidth(), rBmp.GetHeight(),
0, 0, rBmp.GetWidth(), rBmp.GetHeight() 0, 0, rBmp.GetWidth(), rBmp.GetHeight()
}; };
::GpiSetBitmap(hPSSrc, (HBITMAP) pMask->GetMaskBitmap()); if ((hOldBitmap = ::GpiSetBitmap(hPSSrc, (HBITMAP) pMask->GetMaskBitmap())) == HBM_ERROR)
::GpiSetBitmap(hPSDst, (HBITMAP) vIconInfo.hbmColor); {
::GpiBitBlt( hPSDst vError = ::WinGetLastError(vHabmain);
,hPSSrc sError = wxPMErrorToStr(vError);
,4L }
,vPoint if ((hOldBitmap = ::GpiSetBitmap(hPSDst, (HBITMAP) vIconInfo.hbmColor)) == HBM_ERROR)
,ROP_SRCAND {
,BBO_IGNORE vError = ::WinGetLastError(vHabmain);
); sError = wxPMErrorToStr(vError);
}
::GpiSetBitmapId(hPSDst, (HBITMAP) vIconInfo.hbmColor, 1L);
if ((lHits = ::GpiBitBlt( hPSDst
,hPSSrc
,4L
,vPoint
,ROP_SRCAND
,BBO_IGNORE
)) == GPI_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
if ((hOldBitmap = ::GpiSetBitmap(hPSSrc, NULLHANDLE)) == HBM_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
if ((hOldBitmap = ::GpiSetBitmap(hPSDst, NULLHANDLE)) == HBM_ERROR)
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
}
::GpiSetBitmap(hPSSrc, NULL); ::GpiSetBitmap(hPSSrc, NULL);
::GpiSetBitmap(hPSDst, NULL); ::GpiSetBitmap(hPSDst, NULL);
@@ -152,6 +180,8 @@ void wxIcon::CopyFromBitmap(
if (!hIcon) if (!hIcon)
{ {
wxLogLastError(wxT("WinCreatePointerIndirect")); wxLogLastError(wxT("WinCreatePointerIndirect"));
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
} }
else else
{ {

View File

@@ -4,7 +4,7 @@ DATA MULTIPLE NONSHARED READWRITE LOADONCALL
CODE LOADONCALL CODE LOADONCALL
EXPORTS EXPORTS
;From library: F:\DEV\WX2\WXWINDOWS\LIB\wx.lib ;From library: H:\DEV\WX2\WXWINDOWS\LIB\wx.lib
;From object file: dummy.cpp ;From object file: dummy.cpp
;PUBDEFs (Symbols available from object file): ;PUBDEFs (Symbols available from object file):
wxDummyChar wxDummyChar
@@ -1925,7 +1925,7 @@ EXPORTS
wxEVT_NC_LEFT_DCLICK wxEVT_NC_LEFT_DCLICK
wxEVT_INIT_DIALOG wxEVT_INIT_DIALOG
wxEVT_COMMAND_SET_FOCUS wxEVT_COMMAND_SET_FOCUS
;From object file: F:\DEV\WX2\WXWINDOWS\src\common\extended.c ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\extended.c
;PUBDEFs (Symbols available from object file): ;PUBDEFs (Symbols available from object file):
ConvertToIeeeExtended ConvertToIeeeExtended
ConvertFromIeeeExtended ConvertFromIeeeExtended
@@ -6039,7 +6039,7 @@ EXPORTS
Read32__17wxTextInputStreamFv Read32__17wxTextInputStreamFv
;wxTextInputStream::SkipIfEndOfLine(char) ;wxTextInputStream::SkipIfEndOfLine(char)
SkipIfEndOfLine__17wxTextInputStreamFc SkipIfEndOfLine__17wxTextInputStreamFc
;From object file: F:\DEV\WX2\WXWINDOWS\src\common\unzip.c ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\unzip.c
;PUBDEFs (Symbols available from object file): ;PUBDEFs (Symbols available from object file):
unzReadCurrentFile unzReadCurrentFile
unzGetCurrentFileInfo unzGetCurrentFileInfo
@@ -12303,11 +12303,17 @@ EXPORTS
;PUBDEFs (Symbols available from object file): ;PUBDEFs (Symbols available from object file):
;wxMemoryDC::DoDrawRoundedRectangle(int,int,int,int,double) ;wxMemoryDC::DoDrawRoundedRectangle(int,int,int,int,double)
DoDrawRoundedRectangle__10wxMemoryDCFiN31d DoDrawRoundedRectangle__10wxMemoryDCFiN31d
;wxMemoryDC::DoDrawText(const wxString&,int,int)
DoDrawText__10wxMemoryDCFRC8wxStringiT2
;wxMemoryDC::SelectObject(const wxBitmap&) ;wxMemoryDC::SelectObject(const wxBitmap&)
SelectObject__10wxMemoryDCFRC8wxBitmap SelectObject__10wxMemoryDCFRC8wxBitmap
__vft10wxMemoryDC8wxObject __vft10wxMemoryDC8wxObject
;wxMemoryDC::DoDrawLine(int,int,int,int)
DoDrawLine__10wxMemoryDCFiN31
;wxMemoryDC::Init() ;wxMemoryDC::Init()
Init__10wxMemoryDCFv Init__10wxMemoryDCFv
;wxLoadBitmapWithData(unsigned long,unsigned long,int,int)
wxLoadBitmapWithData__FUlT1iT3
;wxMemoryDC::DoGetSize(int*,int*) const ;wxMemoryDC::DoGetSize(int*,int*) const
DoGetSize__10wxMemoryDCCFPiT1 DoGetSize__10wxMemoryDCCFPiT1
;wxMemoryDC::wxMemoryDC(wxDC*) ;wxMemoryDC::wxMemoryDC(wxDC*)