- // scale pixbuf if available and it has alpha or there is no mask
- if (M_BMPDATA->m_pixbuf != NULL && (
- M_BMPDATA->m_mask == NULL || gdk_pixbuf_get_has_alpha(M_BMPDATA->m_pixbuf)))
- {
- bmp.SetPixbuf(gdk_pixbuf_new(GDK_COLORSPACE_RGB,
- gdk_pixbuf_get_has_alpha(M_BMPDATA->m_pixbuf),
- 8, width, height), M_BMPDATA->m_bpp);
- gdk_pixbuf_scale(M_BMPDATA->m_pixbuf, bmp.GetPixbuf(),
- 0, 0, width, height,
- clipx, clipy,
- (double)newx/GetWidth(), (double)newy/GetHeight(),
- GDK_INTERP_BILINEAR);
- }
- else
- {
- GdkImage* img = gdk_drawable_get_image(
- M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height);
-
- wxCHECK_MSG(img, bmp, wxT("couldn't create image"));
-
- GdkGC *gc = NULL;
- GdkPixmap *dstpix = NULL;
- char *dst = NULL;
- long dstbyteperline = 0;
-
- if (GetDepth() != 1)
- {
- bmp.Create(width, height, gdk_drawable_get_depth(M_BMPDATA->m_pixmap));
- dstpix = bmp.GetPixmap();
- gc = gdk_gc_new( dstpix );
- }
- else
- {
- dstbyteperline = (width + 7) / 8;
- dst = (char*) malloc(dstbyteperline*height);
- }
-
- // be careful to use the right scaling factor
- float scx = (float)M_BMPDATA->m_width/(float)newx;
- float scy = (float)M_BMPDATA->m_height/(float)newy;
- // prepare accel-tables
- int *tablex = (int *)calloc(width,sizeof(int));
- int *tabley = (int *)calloc(height,sizeof(int));
-
- // accel table filled with clipped values
- for (int x = 0; x < width; x++)
- tablex[x] = (int) (scx * (x+clipx));
- for (int y = 0; y < height; y++)
- tabley[y] = (int) (scy * (y+clipy));
-
- // Main rescaling routine starts here
- for (int h = 0; h < height; h++)
- {
- char outbyte = 0;
- int old_x = -1;
- guint32 old_pixval = 0;