+ // similarly, created an mono-bitmap for the possible mask
+ if( image.HasMask() )
+ {
+ hbitmap = ::CreateBitmap( (WORD)width, (WORD)bmpHeight, 1, 1, NULL );
+ HGDIOBJ hbmpOld = ::SelectObject( memdc, hbitmap);
+ if( numDIB == 1 ) height = bmpHeight;
+ else height = sizeLimit/bytePerLine;
+ lpDIBh->bmiHeader.biHeight = (DWORD)(-height);
+ lpDIBh->bmiHeader.biSizeImage = bytePerLine*height;
+ origin = 0;
+ unsigned char r = image.GetMaskRed();
+ unsigned char g = image.GetMaskGreen();
+ unsigned char b = image.GetMaskBlue();
+ unsigned char zero = 0, one = 255;
+ ptdata = data;
+ for( n=0; n<numDIB; n++ )
+ {
+ if( numDIB > 1 && n == numDIB - 1 && hRemain > 0 )
+ {
+ // redefine height and size of the (possibly) last smaller DIB
+ // memory is not reallocated
+ height = hRemain;
+ lpDIBh->bmiHeader.biHeight = (DWORD)(-height);
+ lpDIBh->bmiHeader.biSizeImage = bytePerLine*height;
+ }
+ ptbits = lpBits;
+ for( int j=0; j<height; j++ )
+ {
+ for(i=0; i<width; i++ )
+ {
+ // was causing a code gen bug in cw : if( ( cr !=r) || (cg!=g) || (cb!=b) )
+ unsigned char cr = (*(ptdata++)) ;
+ unsigned char cg = (*(ptdata++)) ;
+ unsigned char cb = (*(ptdata++)) ;
+
+ if( ( cr !=r) || (cg!=g) || (cb!=b) )
+ {
+ *(ptbits++) = one;
+ *(ptbits++) = one;
+ *(ptbits++) = one;
+ }
+ else
+ {
+ *(ptbits++) = zero;
+ *(ptbits++) = zero;
+ *(ptbits++) = zero;
+ }
+ }
+ for( i=0; i< padding; i++ ) *(ptbits++) = zero;
+ }
+ ::StretchDIBits( memdc, 0, origin, width, height,\
+ 0, 0, width, height, lpBits, lpDIBh, DIB_RGB_COLORS, SRCCOPY);
+ origin += height;
+ }
+ // create a wxMask object
+ wxMask *mask = new wxMask();
+ mask->SetMaskBitmap( (WXHBITMAP) hbitmap );
+ SetMask( mask );
+ // It will be deleted when the wxBitmap object is deleted (as of 01/1999)
+ /* The following can also be used but is slow to run
+ wxColour colour( GetMaskRed(), GetMaskGreen(), GetMaskBlue());
+ wxMask *mask = new wxMask( *this, colour );
+ SetMask( mask );
+ */
+
+ ::SelectObject( memdc, hbmpOld );
+ }