Results 1 to 10 of 40

Thread: TileStudio for Lazarus

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #29
    I know the code isn't very well structured. The whole project started as a little tool for myself which I kept expanding.

    Can you guys provide some more information about this so together we might try to figure this out.

    Bitmap transparency doesn't seem to work properly in Lazarus (or very different from Delphi at least). At first I thought it didn't work at all (posted an issue here
    http://bugs.freepascal.org/view.php?id=31556 ), but now I see that it does work if you set up the transparent color first. However, once you draw the bitmap onto something else, it forgets its transparent color, but somehow does keep a mask of the transparency you had before. In Delphi, you can just set the transparent color at any time and it will draw the image accordingly. Here is a simple program that behaves differently in Lazarus and Delphi, see the result image below.


    Code:
    procedure TForm1.BitBtn1Click(Sender: TObject);
      var
        bmp1: TBitmap;
    begin
      bmp1 := TBitmap.Create();
      bmp1.Transparent := TRUE;
      bmp1.TransparentColor := clRed;
    
      bmp1.Width := 100;
      bmp1.Height := 100;
      with bmp1.Canvas do
      begin
        Brush.Color := clRed;
        FillRect(Rect(0, 0, 100, 100));
        Brush.Color := clYellow;
        FillRect(Rect(20, 20, 80, 80));
      end;
    
      Image1.Picture.Bitmap := TBitmap.Create();
      Image1.Picture.Bitmap.Width := 100;
      Image1.Picture.Bitmap.Height := 100;
      with Image1.Picture.Bitmap.Canvas do
      begin
        Brush.Color := clGreen;
        FillRect (Rect(0, 0, 100, 100));
        Draw(0, 0, bmp1);
      end;
    
      with bmp1.Canvas do
      begin
        Brush.Color := clBlue;
        FillRect(Rect(0, 0, 50, 50));
        Brush.Color := clRed;
        FillRect (Rect(50, 50, 100, 100));
      end;
    
      with Image1.Picture.Bitmap.Canvas do
      begin
        Brush.Color := clGreen;
        FillRect (Rect(0, 0, 100, 100));
        Draw(0, 0, bmp1);
      end;
    end;



    [Edit] I found a workaround by adding Bitmap.Mask() before every Draw, which is probably very inefficient, but now the maps are rendered correctly.
    Attached Images Attached Images
    Last edited by Wiering; 18-03-2017 at 10:07 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •