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

Reply via email to