Fix for upside down bmp projections
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15478 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -217,7 +217,6 @@ public:
|
|||||||
{ return (GetBitmapData() ? GetBitmapData()->m_pSelectedInto : (wxDC*) NULL); }
|
{ return (GetBitmapData() ? GetBitmapData()->m_pSelectedInto : (wxDC*) NULL); }
|
||||||
|
|
||||||
inline bool IsMono(void) const { return m_bIsMono; }
|
inline bool IsMono(void) const { return m_bIsMono; }
|
||||||
inline bool Flip(void) const { return m_bFlip; }
|
|
||||||
|
|
||||||
|
|
||||||
// An OS/2 version that probably doesn't do anything like the msw version
|
// An OS/2 version that probably doesn't do anything like the msw version
|
||||||
@@ -242,7 +241,6 @@ private:
|
|||||||
bool CopyFromIconOrCursor(const wxGDIImage& rIcon);
|
bool CopyFromIconOrCursor(const wxGDIImage& rIcon);
|
||||||
|
|
||||||
bool m_bIsMono;
|
bool m_bIsMono;
|
||||||
bool m_bFlip;
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
||||||
}; // end of CLASS wxBitmap
|
}; // end of CLASS wxBitmap
|
||||||
|
|
||||||
|
@@ -90,7 +90,6 @@ void wxBitmap::Init()
|
|||||||
//
|
//
|
||||||
// True for all bitmaps created from bits, wxImages, Xpms
|
// True for all bitmaps created from bits, wxImages, Xpms
|
||||||
//
|
//
|
||||||
m_bFlip = TRUE;
|
|
||||||
} // end of wxBitmap::Init
|
} // end of wxBitmap::Init
|
||||||
|
|
||||||
bool wxBitmap::CopyFromIconOrCursor(
|
bool wxBitmap::CopyFromIconOrCursor(
|
||||||
@@ -269,7 +268,6 @@ wxBitmap::wxBitmap(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
m_bFlip = FALSE;
|
|
||||||
(void)Create( nW
|
(void)Create( nW
|
||||||
,nH
|
,nH
|
||||||
,nD
|
,nD
|
||||||
@@ -300,7 +298,6 @@ wxBitmap::wxBitmap(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
m_bFlip = FALSE;
|
|
||||||
LoadFile( rFilename
|
LoadFile( rFilename
|
||||||
,(int)lType
|
,(int)lType
|
||||||
);
|
);
|
||||||
@@ -326,8 +323,6 @@ bool wxBitmap::Create(
|
|||||||
// Xpms and bitmaps from other images can also be mono's, but only
|
// Xpms and bitmaps from other images can also be mono's, but only
|
||||||
// mono's need help changing their colors with MemDC changes
|
// mono's need help changing their colors with MemDC changes
|
||||||
//
|
//
|
||||||
if (nD == 1)
|
|
||||||
m_bIsMono = TRUE;
|
|
||||||
if (nD > 0)
|
if (nD > 0)
|
||||||
{
|
{
|
||||||
DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
|
DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
|
||||||
@@ -335,6 +330,8 @@ bool wxBitmap::Create(
|
|||||||
HDC hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
|
HDC hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
|
||||||
HPS hPS = ::GpiCreatePS(vHabmain, hDC, &vSize, PU_PELS | GPIA_ASSOC);
|
HPS hPS = ::GpiCreatePS(vHabmain, hDC, &vSize, PU_PELS | GPIA_ASSOC);
|
||||||
|
|
||||||
|
if (nD == 1)
|
||||||
|
m_bIsMono = TRUE;
|
||||||
memset(&vHeader, '\0', 16);
|
memset(&vHeader, '\0', 16);
|
||||||
vHeader.cbFix = 16;
|
vHeader.cbFix = 16;
|
||||||
vHeader.cx = nW;
|
vHeader.cx = nW;
|
||||||
@@ -526,7 +523,6 @@ bool wxBitmap::CreateFromImage (
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG(rImage.Ok(), FALSE, wxT("invalid image"));
|
wxCHECK_MSG(rImage.Ok(), FALSE, wxT("invalid image"));
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
m_bFlip = TRUE;
|
|
||||||
|
|
||||||
int nSizeLimit = 1024 * 768 * 3;
|
int nSizeLimit = 1024 * 768 * 3;
|
||||||
int nWidth = rImage.GetWidth();
|
int nWidth = rImage.GetWidth();
|
||||||
@@ -565,6 +561,10 @@ bool wxBitmap::CreateFromImage (
|
|||||||
wxCHECK_MSG(rImage.Ok(), FALSE, wxT("invalid image"));
|
wxCHECK_MSG(rImage.Ok(), FALSE, wxT("invalid image"));
|
||||||
SetWidth(nWidth);
|
SetWidth(nWidth);
|
||||||
SetHeight(nBmpHeight);
|
SetHeight(nBmpHeight);
|
||||||
|
if (nDepth == 1)
|
||||||
|
m_bIsMono = TRUE;
|
||||||
|
else
|
||||||
|
m_bIsMono = FALSE;
|
||||||
if (nDepth == -1)
|
if (nDepth == -1)
|
||||||
nDepth = wxDisplayDepth();
|
nDepth = wxDisplayDepth();
|
||||||
SetDepth(nDepth);
|
SetDepth(nDepth);
|
||||||
@@ -770,6 +770,7 @@ bool wxBitmap::CreateFromImage (
|
|||||||
//
|
//
|
||||||
nHeight = nHRemain;
|
nHeight = nHRemain;
|
||||||
vHeader.cy = (DWORD)(nHeight);
|
vHeader.cy = (DWORD)(nHeight);
|
||||||
|
vHeader.cbImage = nBytePerLine * nHeight;
|
||||||
}
|
}
|
||||||
ptbits = pucBits;
|
ptbits = pucBits;
|
||||||
for (int j = 0; j < nHeight; j++)
|
for (int j = 0; j < nHeight; j++)
|
||||||
|
@@ -1147,8 +1147,8 @@ void wxDC::DoDrawRoundedRectangle(
|
|||||||
::GpiBox( m_hPS
|
::GpiBox( m_hPS
|
||||||
,lControl
|
,lControl
|
||||||
,&vPoint[1]
|
,&vPoint[1]
|
||||||
,0L
|
,(LONG)dRadius
|
||||||
,0L
|
,(LONG)dRadius
|
||||||
);
|
);
|
||||||
lControl = DRO_FILL;
|
lControl = DRO_FILL;
|
||||||
::GpiSetColor( m_hPS
|
::GpiSetColor( m_hPS
|
||||||
@@ -1162,8 +1162,8 @@ void wxDC::DoDrawRoundedRectangle(
|
|||||||
::GpiBox( m_hPS
|
::GpiBox( m_hPS
|
||||||
,lControl
|
,lControl
|
||||||
,&vPoint[1]
|
,&vPoint[1]
|
||||||
,0L
|
,(LONG)dRadius
|
||||||
,0L
|
,(LONG)dRadius
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1314,31 +1314,14 @@ void wxDC::DoDrawBitmap(
|
|||||||
|
|
||||||
vY = OS2Y(vY,rBmp.GetHeight());
|
vY = OS2Y(vY,rBmp.GetHeight());
|
||||||
|
|
||||||
//
|
vPoint[0].x = vX;
|
||||||
// Flip the picture as OS/2 is upside-down
|
vPoint[0].y = vY + rBmp.GetHeight();
|
||||||
//
|
vPoint[1].x = vX + rBmp.GetWidth();
|
||||||
if (rBmp.Flip())
|
vPoint[1].y = vY;
|
||||||
{
|
vPoint[2].x = 0;
|
||||||
vPoint[0].x = vX;
|
vPoint[2].y = 0;
|
||||||
vPoint[0].y = vY + rBmp.GetHeight();
|
vPoint[3].x = rBmp.GetWidth();
|
||||||
vPoint[1].x = vX + rBmp.GetWidth();
|
vPoint[3].y = rBmp.GetHeight();
|
||||||
vPoint[1].y = vY;
|
|
||||||
vPoint[2].x = 0;
|
|
||||||
vPoint[2].y = 0;
|
|
||||||
vPoint[3].x = rBmp.GetWidth();
|
|
||||||
vPoint[3].y = rBmp.GetHeight();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vPoint[0].x = vX;
|
|
||||||
vPoint[0].y = vY;
|
|
||||||
vPoint[1].x = vX + rBmp.GetWidth();
|
|
||||||
vPoint[1].y = vY + rBmp.GetHeight();
|
|
||||||
vPoint[2].x = 0;
|
|
||||||
vPoint[2].y = 0;
|
|
||||||
vPoint[3].x = rBmp.GetWidth();
|
|
||||||
vPoint[3].y = rBmp.GetHeight();
|
|
||||||
}
|
|
||||||
if (bUseMask)
|
if (bUseMask)
|
||||||
{
|
{
|
||||||
wxMask* pMask = rBmp.GetMask();
|
wxMask* pMask = rBmp.GetMask();
|
||||||
@@ -1786,14 +1769,14 @@ void wxDC::DrawAnyText(
|
|||||||
m_vRclPaint.yBottom == 0 &&
|
m_vRclPaint.yBottom == 0 &&
|
||||||
m_vRclPaint.xRight == 0 &&
|
m_vRclPaint.xRight == 0 &&
|
||||||
m_vRclPaint.xLeft == 0))
|
m_vRclPaint.xLeft == 0))
|
||||||
vPtlStart.y = OS2Y(vY,vTextY);
|
vPtlStart.y = OS2Y(vY,vTextY/1.5); // Full extent is a bit much
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_vSelectedBitmap != wxNullBitmap)
|
if (m_vSelectedBitmap != wxNullBitmap)
|
||||||
{
|
{
|
||||||
m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
|
m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
|
||||||
m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
|
m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
|
||||||
vPtlStart.y = OS2Y(vY,vTextY);
|
vPtlStart.y = OS2Y(vY,vTextY/1.5);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vPtlStart.y = vY;
|
vPtlStart.y = vY;
|
||||||
|
@@ -150,6 +150,22 @@ void wxMemoryDC::SelectObject(
|
|||||||
|
|
||||||
if (!hBmp)
|
if (!hBmp)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// Bmps drawn to are upside down, so flip it before committing
|
||||||
|
//
|
||||||
|
POINTL vPoint[4] = { 0, m_vSelectedBitmap.GetHeight(),
|
||||||
|
m_vSelectedBitmap.GetWidth(), 0,
|
||||||
|
0, 0, m_vSelectedBitmap.GetWidth(), m_vSelectedBitmap.GetHeight()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
::GpiBitBlt( m_hPS
|
||||||
|
,m_hPS
|
||||||
|
,4
|
||||||
|
,vPoint
|
||||||
|
,ROP_SRCCOPY
|
||||||
|
,BBO_IGNORE
|
||||||
|
);
|
||||||
m_vSelectedBitmap.SetSelectedInto(NULL);
|
m_vSelectedBitmap.SetSelectedInto(NULL);
|
||||||
}
|
}
|
||||||
m_vSelectedBitmap = rBitmap;
|
m_vSelectedBitmap = rBitmap;
|
||||||
@@ -157,6 +173,7 @@ void wxMemoryDC::SelectObject(
|
|||||||
|
|
||||||
if (!hBmp)
|
if (!hBmp)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_hOldBitmap = (WXHBITMAP)::GpiSetBitmap(m_hPS, NULLHANDLE);
|
m_hOldBitmap = (WXHBITMAP)::GpiSetBitmap(m_hPS, NULLHANDLE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user