While I don't have an answer for you, I can add more information.

GamePack development highlighted the same - as yet I could not find a 
sollution - but I CAN add that it ONLY seems to affect win32.
Under GTK at least, transparency for sprites worked perfectly.

A.J.
On Monday 11 December 2006 11:35, Andreas Berger wrote:
> Well, I finally had time to try transparent images again. This is
> important for me since it is the last factor that is keeping me from
> migrating totally to fpc. Actually transparent bitmaps work, but sprites
> (copying portions of an image transparently to the main canvas) didn't.
> Here is the delphi code:
>
> 1     bmp := TBitmap.Create;
> 2     bmp.Width := w;
> 3     bmp.Height := h;
> 4     bmp.Canvas.CopyRect(bmp.Canvas.ClipRect, Image.Canvas, Rect(x*w,
> y*h, x*w+w, y*h+h));
> 5{$ifdef fpc}
> 6     f := TMemoryStream.Create;
> 7     try
> 8        bmp.SaveToStream(f);
> 9        f.position := 0;
> 10      bmp.LoadFromStream(f);
> 11   finally
> 12      f.Free();
> 13   end;
> 14{$endif}
> 15    bmp.Transparent := true;
> 16    bmp.TransparentColor := bmp.Canvas.Pixels[0, 0];
> 17    Canvas.Draw(0, 0, bmp)
>
>
> This works perfectly in Delphi, but never worked in FPC. I finally found
> the problem: ClipRect is incorrect at this stage. Instead I changed line
> 4 to:
>
> 4     bmp.Canvas.CopyRect(Rect(0, 0, w, h), Image.Canvas, Rect(x*w, y*h,
> x*w+w, y*h+h));
>
> Now transparency works.
>
> What I still don't like is the need to save to a memory stream and read
> it back (I think it was I that discovered this trick a long time ago).
> Can one of the graphics gurus say if this is easy to fix?
>
> Regards,
> Andreas
>
> _________________________________________________________________
>      To unsubscribe: mail [EMAIL PROTECTED] with
>                 "unsubscribe" as the Subject
>    archives at http://www.lazarus.freepascal.org/mailarchives

-- 
"Software developers have become adept at the difficult art of building 
reasonably reliable systems out of unreliable parts." - Bjarne Stroustrup 
A.J. Venter
Chief Software Architect
OpenLab International           | +27 83 455 99 78 (South Africa) 
http://www.getopenlab.com       | 086 654 2898 (Fax)
http://www.silentcoder.co.za    | +55 118 162 2079 (Brazil)
GPG Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x27CFFE5A

Attachment: pgpdKafWMn2uA.pgp
Description: PGP signature

Reply via email to