UnRef();
}
-wxImage wxImage::Scale( int width, int height )
+wxImage wxImage::Scale( int width, int height ) const
{
wxImage image;
wxBitmap wxImage::ConvertToBitmap() const
{
+ if ( !Ok() )
+ return wxNullBitmap;
+
// sizeLimit is the MS upper limit for the DIB size
int sizeLimit = 1024*768*3;
// 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
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++;
}
// 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;
}
// Retrieve depth
GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() );
- if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
+ if (visual == NULL) visual = gdk_visual_get_system();
int bpp = visual->depth;
bitmap.SetDepth( bpp );
{
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;
vi = XGetVisualInfo( dpy, VisualIDMask|VisualDepthMask, &vinfo_template, &nitem );
- wxCHECK_MSG( vi, wxNullBitmap, _T("no visual") );
+ wxCHECK_RET( vi, _T("no visual") );
if ((bpp == 16) && (vi->red_mask != 0xf800)) bpp = 15;