- if (bpp == 1)
- {
- bmp = wxBitmap( (const char *)dst, width, height, 1 );
- free( dst );
- }
-
- if (GetMask())
- {
- dstbyteperline = width/8;
- if (width % 8 != 0)
- dstbyteperline++;
- dst = (char*) malloc(dstbyteperline*height);
- img = gdk_image_get( GetMask()->GetBitmap(), 0, 0, GetWidth(), GetHeight() );
-
- for (int h = 0; h < height; h++)
- {
- char outbyte = 0;
- int old_x = -1;
- guint32 old_pixval = 0;
-
- for (int w = 0; w < width; w++)
- {
- guint32 pixval;
- int x = tablex[w];
- if (x == old_x)
- pixval = old_pixval;
- else
- {
- pixval = gdk_image_get_pixel( img, x, tabley[h] );
- old_pixval = pixval;
- old_x = x;
- }
-
- if (pixval)
- {
- char bit=1;
- char shift = bit << w % 8;
- outbyte |= shift;
- }
-
- if ((w+1)%8 == 0)
- {
- dst[h*dstbyteperline+w/8] = outbyte;
- outbyte = 0;
- }
- }
-
- // do not forget the last byte
- if (width % 8 != 0)
- dst[h*dstbyteperline+width/8] = outbyte;
- }
- wxMask* mask = new wxMask;
- mask->m_bitmap = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) dst, width, height );
- bmp.SetMask(mask);