+ 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( j=0; j<height; j++ )
+ {
+ for( i=0; i<width; i++ )
+ {
+ *(ptbits++) = *(ptdata+2);
+ *(ptbits++) = *(ptdata+1);
+ *(ptbits++) = *(ptdata );
+ ptdata += 3;
+ }
+ for( i=0; i< padding; i++ ) *(ptbits++) = 0;
+ }
+ ::StretchDIBits( memdc, 0, origin, width, height,\
+ 0, 0, width, height, lpBits, lpDIBh, DIB_RGB_COLORS, SRCCOPY);
+ origin += height;
+ // if numDIB = 1, lines below can also be used
+ // hbitmap = CreateDIBitmap( hdc, &(lpDIBh->bmiHeader), CBM_INIT, lpBits, lpDIBh, DIB_RGB_COLORS );
+ // The above line is equivalent to the following two lines.
+ // hbitmap = ::CreateCompatibleBitmap( hdc, width, height );
+ // ::SetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS);
+ // or the following lines
+ // hbitmap = ::CreateCompatibleBitmap( hdc, width, height );
+ // HDC memdc = ::CreateCompatibleDC( hdc );
+ // ::SelectObject( memdc, hbitmap);
+ // ::SetDIBitsToDevice( memdc, 0, 0, width, height,
+ // 0, 0, 0, height, (void *)lpBits, lpDIBh, DIB_RGB_COLORS);
+ // ::SelectObject( memdc, 0 );
+ // ::DeleteDC( memdc );
+ }
+ SetHBITMAP( (WXHBITMAP) hbitmap );