[fpc-pascal] fpGUI Toolkit on WinCE

Adrian Veith adrian at veith-system.de
Tue Mar 16 14:03:08 CET 2010


Am 16.03.2010 13:17, schrieb Adrian Veith:
> 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).
>>
>>     
Now my second solution works:

{$IFDEF wince}
procedure WinCESetDibBits(BMP: HBITMAP; awidth, aheight: Integer;
aimgdata: Pointer; var bi: TBitmapInfo);
var
  hdcSrc, hdcDest: HDC;
  hbmSrc: HBITMAP;
  bm: BITMAP;
begin
  hdcDest:= CreateCompatibleDC(0);
  SelectObject(hdcDest, BMP);
  if bi.bmiHeader.biBitCount = 1 then begin
    SetDIBitsToDevice(hdcDest, 0, 0, awidth, aheight, 0, 0, 0, aheight,
aimgdata, bi, DIB_RGB_COLORS);
  end else begin
    hdcSrc:= CreateCompatibleDC(0);
    hbmSrc:= CreateBitmap(awidth, aheight, 1, bi.bmiHeader.biBitCount,
aimgdata);
    SelectObject(hdcSrc, hbmSrc);
    BitBlt(hdcDest, 0, 0, awidth, aheight, hdcSrc, 0, 0, SRCCOPY);
    DeleteDC(hdcSrc);
    DeleteObject(hbmSrc);
  end;
  DeleteDC(hdcDest);
end;

{$ENDIF}

and the change for TfpgGDIImage.DoInitImage:

  {$IFNDEF wince}
  SetDIBits(wapplication.display, FBMPHandle, 0, aheight, aimgdata, bi,
DIB_RGB_COLORS);
  {$else}
  WinCESetDibBits(FBMPHandle, awidth, aheight, aimgdata, bi);
  {$ENDIF}


and for TfpgGDIImage.DoInitImageMask

  {$IFNDEF wince}
  SetDIBits(wapplication.display, FMaskHandle, 0, aheight, aimgdata,
pbi^, DIB_RGB_COLORS);
  {$ELSE}
  WinCESetDibBits(FMaskHandle, awidth, aheight, aimgdata, pbi^);
  {$ENDIF}

with the patch for loading 32bit bitmaps posted before you can call
fpgCreateStandardImages; in fpg_main:

  {--$IFNDEF wince}
  fpgCreateStandardImages;
  (*  causes EBusError on Symbol MC1000 WinCE 4.2
  see: http://wiki.freepascal.org/Windows_CE_Development_Notes
  "Using ARM processors, some times you may get a EBusError exception with
  a message about misaligned data access.  The following section explains
  what this is and how to fix it." - fixed
  *)
  {--$ENDIF}

cheers Adrian.




More information about the fpc-pascal mailing list