]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
compile fixes for EMX
[wxWidgets.git] / src / common / image.cpp
index 8ef0b3429a540af8d739a6563e5f73c1aae22305..18d73f4668482450d34361bd38ea46e588c4ec6d 100644 (file)
@@ -150,7 +150,7 @@ void wxImage::Destroy()
     UnRef();
 }
 
-wxImage wxImage::Scale( int width, int height )
+wxImage wxImage::Scale( int width, int height ) const
 {
     wxImage image;
 
@@ -582,6 +582,9 @@ bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSE
 
 wxBitmap wxImage::ConvertToBitmap() const
 {
+    if ( !Ok() )
+        return wxNullBitmap;
+
     // sizeLimit is the MS upper limit for the DIB size
     int sizeLimit = 1024*768*3;
 
@@ -592,11 +595,11 @@ wxBitmap wxImage::ConvertToBitmap() const
     // calc the number of bytes per scanline and padding
     int bytePerLine = width*3;
     int sizeDWORD = sizeof( DWORD );
-    div_t lineBoundary = div( bytePerLine, sizeDWORD );
+    int lineBoundary = bytePerLine % sizeDWORD;
     int padding = 0;
-    if( lineBoundary.rem > 0 )
+    if( lineBoundary > 0 )
     {
-        padding = sizeDWORD - lineBoundary.rem;
+        padding = sizeDWORD - lineBoundary;
         bytePerLine += padding;
     }
     // calc the number of DIBs and heights of DIBs
@@ -607,9 +610,8 @@ wxBitmap wxImage::ConvertToBitmap() const
         height = bmpHeight;
     else
     {
-        div_t result = div( bmpHeight, height );
-        numDIB = result.quot;
-        hRemain = result.rem;
+        numDIB =  bmpHeight / height;
+        hRemain = bmpHeight % height;
         if( hRemain >0 )  numDIB++;
     }
 
@@ -805,11 +807,11 @@ wxImage::wxImage( const wxBitmap &bitmap )
     // calc the number of bytes per scanline and padding in the DIB
     int bytePerLine = width*3;
     int sizeDWORD = sizeof( DWORD );
-    div_t lineBoundary = div( bytePerLine, sizeDWORD );
+    int lineBoundary =  bytePerLine % sizeDWORD;
     int padding = 0;
-    if( lineBoundary.rem > 0 )
+    if( lineBoundary > 0 )
     {
-        padding = sizeDWORD - lineBoundary.rem;
+        padding = sizeDWORD - lineBoundary;
         bytePerLine += padding;
     }
 
@@ -944,7 +946,7 @@ wxBitmap wxImage::ConvertToBitmap() const
      // Retrieve depth
 
     GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() );
-    if (visual == NULL) visual = gdk_visual_get_best();
+    if (visual == NULL) visual = gdk_visual_get_system();
     int bpp = visual->depth;
 
     bitmap.SetDepth( bpp );
@@ -984,7 +986,7 @@ wxBitmap wxImage::ConvertToBitmap() const
     // Create picture image
 
     GdkImage *data_image =
-        gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_best(), width, height );
+        gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height );
 
     // Create mask image
 
@@ -994,7 +996,7 @@ wxBitmap wxImage::ConvertToBitmap() const
     {
         unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
 
-        mask_image =  gdk_image_new_bitmap( gdk_visual_get_best(), mask_data, width, height );
+        mask_image =  gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height );
 
         wxMask *mask = new wxMask();
         mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 );
@@ -1009,7 +1011,7 @@ wxBitmap wxImage::ConvertToBitmap() const
 
     if (bpp >= 24)
     {
-        GdkVisual *visual = gdk_visual_get_best();
+        GdkVisual *visual = gdk_visual_get_system();
         if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask))      b_o = RGB;
         else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask))  b_o = RGB;
         else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask))   b_o = BRG;
@@ -1179,7 +1181,8 @@ wxImage::wxImage( const wxBitmap &bitmap )
     {
         for (int i = 0; i < bitmap.GetWidth(); i++)
         {
-            int pixel = gdk_image_get_pixel( gdk_image, i, j );
+            wxInt32 pixel = gdk_image_get_pixel( gdk_image, i, j );
+           pixel = wxINT32_SWAP_ON_BE( pixel );
             if (bpp <= 8)
             {
                 data[pos] = cmap->colors[pixel].red >> 8;