]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix for upside down bmp projections
authorDavid Webster <Dave.Webster@bhmi.com>
Fri, 10 May 2002 04:09:27 +0000 (04:09 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Fri, 10 May 2002 04:09:27 +0000 (04:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15478 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/os2/bitmap.h
src/os2/bitmap.cpp
src/os2/dc.cpp
src/os2/dcmemory.cpp

index de14c11b1af2cfad96648dc76add43033ae83e21..68efa967580514958d5a793a624d68807a257eba 100644 (file)
@@ -217,7 +217,6 @@ public:
       { return (GetBitmapData() ? GetBitmapData()->m_pSelectedInto : (wxDC*) NULL); }
 
     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
@@ -242,7 +241,6 @@ private:
     bool CopyFromIconOrCursor(const wxGDIImage& rIcon);
 
     bool                            m_bIsMono;
-    bool                            m_bFlip;
     DECLARE_DYNAMIC_CLASS(wxBitmap)
 }; // end of CLASS wxBitmap
 
index 2a88e27107cf0831d825eeae50620cef66fcfbc5..92ca4c551ee821f396dbb28174c1cb58b98d2fb9 100644 (file)
@@ -90,7 +90,6 @@ void wxBitmap::Init()
     //
     // True for all bitmaps created from bits, wxImages, Xpms
     //
-    m_bFlip = TRUE;
 } // end of wxBitmap::Init
 
 bool wxBitmap::CopyFromIconOrCursor(
@@ -269,7 +268,6 @@ wxBitmap::wxBitmap(
 )
 {
     Init();
-    m_bFlip = FALSE;
     (void)Create( nW
                  ,nH
                  ,nD
@@ -300,7 +298,6 @@ wxBitmap::wxBitmap(
 )
 {
     Init();
-    m_bFlip = FALSE;
     LoadFile( rFilename
              ,(int)lType
             );
@@ -326,8 +323,6 @@ bool wxBitmap::Create(
     // Xpms and bitmaps from other images can also be mono's, but only
     // mono's need help changing their colors with MemDC changes
     //
-    if (nD == 1)
-        m_bIsMono = TRUE;
     if (nD > 0)
     {
         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);
         HPS                         hPS   = ::GpiCreatePS(vHabmain, hDC, &vSize, PU_PELS | GPIA_ASSOC);
 
+        if (nD == 1)
+            m_bIsMono = TRUE;
         memset(&vHeader, '\0', 16);
         vHeader.cbFix     =  16;
         vHeader.cx        = nW;
@@ -526,7 +523,6 @@ bool wxBitmap::CreateFromImage (
 {
     wxCHECK_MSG(rImage.Ok(), FALSE, wxT("invalid image"));
     m_refData = new wxBitmapRefData();
-    m_bFlip = TRUE;
 
     int                             nSizeLimit = 1024 * 768 * 3;
     int                             nWidth = rImage.GetWidth();
@@ -565,6 +561,10 @@ bool wxBitmap::CreateFromImage (
     wxCHECK_MSG(rImage.Ok(), FALSE, wxT("invalid image"));
     SetWidth(nWidth);
     SetHeight(nBmpHeight);
+    if (nDepth == 1)
+        m_bIsMono = TRUE;
+    else
+        m_bIsMono = FALSE;
     if (nDepth == -1)
         nDepth = wxDisplayDepth();
     SetDepth(nDepth);
@@ -770,6 +770,7 @@ bool wxBitmap::CreateFromImage (
                 //
                 nHeight         = nHRemain;
                 vHeader.cy      = (DWORD)(nHeight);
+                vHeader.cbImage = nBytePerLine * nHeight;
             }
             ptbits = pucBits;
             for (int j = 0; j < nHeight; j++)
index e8b4b76ba3690c123490d7ca68c0dac068c04127..405ab5b9c251a35156198716ab979726594fe096 100644 (file)
@@ -1147,8 +1147,8 @@ void wxDC::DoDrawRoundedRectangle(
         ::GpiBox( m_hPS
                  ,lControl
                  ,&vPoint[1]
-                 ,0L
-                 ,0L
+                 ,(LONG)dRadius
+                 ,(LONG)dRadius
                 );
         lControl = DRO_FILL;
         ::GpiSetColor( m_hPS
@@ -1162,8 +1162,8 @@ void wxDC::DoDrawRoundedRectangle(
         ::GpiBox( m_hPS
                  ,lControl
                  ,&vPoint[1]
-                 ,0L
-                 ,0L
+                 ,(LONG)dRadius
+                 ,(LONG)dRadius
                 );
     }
 
@@ -1314,31 +1314,14 @@ void wxDC::DoDrawBitmap(
 
         vY = OS2Y(vY,rBmp.GetHeight());
 
-        //
-        // Flip the picture as OS/2 is upside-down
-        //
-        if (rBmp.Flip())
-        {
-            vPoint[0].x = vX;
-            vPoint[0].y = vY + rBmp.GetHeight();
-            vPoint[1].x = vX + rBmp.GetWidth();
-            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();
-        }
+        vPoint[0].x = vX;
+        vPoint[0].y = vY + rBmp.GetHeight();
+        vPoint[1].x = vX + rBmp.GetWidth();
+        vPoint[1].y = vY;
+        vPoint[2].x = 0;
+        vPoint[2].y = 0;
+        vPoint[3].x = rBmp.GetWidth();
+        vPoint[3].y = rBmp.GetHeight();
         if (bUseMask)
         {
             wxMask*                     pMask = rBmp.GetMask();
@@ -1786,14 +1769,14 @@ void wxDC::DrawAnyText(
           m_vRclPaint.yBottom == 0 &&
           m_vRclPaint.xRight == 0 &&
           m_vRclPaint.xLeft == 0))
-        vPtlStart.y = OS2Y(vY,vTextY);
+        vPtlStart.y = OS2Y(vY,vTextY/1.5); // Full extent is a bit much
     else
     {
         if (m_vSelectedBitmap != wxNullBitmap)
         {
             m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
             m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
-            vPtlStart.y = OS2Y(vY,vTextY);
+            vPtlStart.y = OS2Y(vY,vTextY/1.5);
         }
         else
             vPtlStart.y = vY;
index 8dc8321f7730d6bca0384b68a6cb143e1ccde68e..5e2ed33694f245e22181a3e82abf5f047ec5ca69 100644 (file)
@@ -150,6 +150,22 @@ void wxMemoryDC::SelectObject(
 
     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 = rBitmap;
@@ -157,6 +173,7 @@ void wxMemoryDC::SelectObject(
 
     if (!hBmp)
     {
+
         m_hOldBitmap = (WXHBITMAP)::GpiSetBitmap(m_hPS, NULLHANDLE);
         return;
     }