[fpc-pascal] fpGUI Toolkit on WinCE

Adrian Veith adrian at veith-system.de
Tue Mar 16 13:17:51 CET 2010

Am 16.03.2010 11:22, schrieb Adrian Veith:
> Am 16.03.2010 10:45, schrieb Matt Emson:
>> Adrian Veith wrote:
>>> ..the bitmaps look scrambled and have different colors.
>>> I haven't found the solution for this yet.
>> Ignore that last message. It seems WinCE is only ever little endian.
>> So it is probably more to do with DIB vs general device dependent
>> Bitmaps. Have you tried converting the bitmap in question to a DIB?
> I am so far that I found that the procedure SetDIBits is not supported
> on WinCE (that's why it is commented out in the WinCE build). So the
> Bitmap is not initialized with the data loaded from the file and shows
> random crap.
> I have to find  way how to initialize the bitmap without SetDIBits (and
> in a efficient way).

My solution for the moment is:

{$IFDEF wince}
procedure WinCESetInitBMP(BMP: HBITMAP; awidth, aheight, depth: Integer;
aimgdata: Pointer);
  hdcSrc, hdcDest: HDC;
  hbmSrc: HBITMAP;
  bm: BITMAP;
  data, p, pend: pByte;
  hdcSrc:= CreateCompatibleDC(0);
  hdcDest:= CreateCompatibleDC(0);
  hbmSrc:= CreateBitmap(awidth, aheight, 1, depth, nil);
  if depth = 32 then
    SetBitmapBits(hbmSrc, (awidth * aheight) *4, aimgdata)
    SetBitmapBits(hbmSrc, (awidth * aheight) div 8, aimgdata);
  SelectObject(hdcSrc, hbmSrc);
  SelectObject(hdcDest, BMP);
  BitBlt(hdcDest, 0, 0, awidth, aheight, hdcSrc, 0, 0, SRCCOPY);

and change the code in TfpgGDIImage.DoInitImage to

  {$IFNDEF wince}
  SetDIBits(wapplication.display, FBMPHandle, 0, aheight, aimgdata, bi,
  WinCESetInitBMP(FBMPHandle, awidth, aheight, bi.bmiHeader.biBitCount,

and in TfpgGDIImage.DoInitImageMask to:

  {$IFNDEF wince}
  SetDIBits(wapplication.display, FMaskHandle, 0, aheight, aimgdata,
  WinCESetInitBMP(FMaskHandle, awidth, aheight, bi.bmiHeader.biBitCount,

now bitmaps are loaded an painted correctly, but still the stdimg.xxx
(e.g. stdimg.close) are not painted correctly 
- I guess there is a problem with the masking.


More information about the fpc-pascal mailing list