Recent

Author Topic: TImage and transparency  (Read 5446 times)

Lord_Eirik

  • Newbie
  • Posts: 1
TImage and transparency
« on: October 01, 2006, 08:03:46 pm »
I have a problem with TImage and transparency.

I have an image that I use as a spritesheet, then I copy sprites out of that image.

I use this code:
Code: [Select]

a: TRect;
b: TRect;
i: integer;
begin
  a.Left := 0;
  b.Left := 0;
  a.Top := 0;
  b.Top := 0;
  a.Right := 28;
  b.Right := 28;
  a.Bottom := 33;
  b.Bottom := 33;
  for i := 1 to 1 do
  begin
    WalkU1[i] := TImage.Create(self);
    with WalkU1[i] do
    begin
     Transparent := true;
      Parent := CharImages;
      Width := 28;
      Height := 33;
      Tag := i;
      Canvas.CopyRect(a, Image1.Canvas , b);
    end;
  end;  
end;        
   


Problem: The image that is created is not transparent as it should be.
Note:
- Image1 is the spritesheet and WalkU1: array [1..1000] of TImage;
- The picture is perfectly copied
- I use win32
- I have tried both with bmp and jpg.
- I have tried both WalkU1[1].Update; and WalkU1[1].Refresh; after creating.
- I do not want to use OpenGL/DX

And also:
When I use Canvas.CopyRect(Rect(0,0,28,33), Image7.Canvas , b); I get
Unit1.pas(456,29) Fatal: Syntax error, ")" expected but "," found

Please help me!

Found the error of the Rect();
It is because I use Windows;
When "uses Windows;" I can't use bmp: TBitmap; bmp := TBitmap.Create; either.

Antrepolit

  • New member
  • *
  • Posts: 7
    • http://www.c-gen.net.tc
TImage and transparency
« Reply #1 on: October 06, 2006, 07:24:55 am »
I guess the Transparency isn't yet implemented.

Last weekend, I was reading the INC file, that includes the Bitmap operations, and at some lines I found the comments "Not implemented" or something like that.

Maybe in Version 0.9.xx...

RudieD

  • Full Member
  • ***
  • Posts: 234
TImage and transparency
« Reply #2 on: October 06, 2006, 05:04:18 pm »
I just set the Bitmap.TransparentColor := Bitmap.Canvas.Pixels[0,0]; before I set the Bitmap.Transparent := True;.
The FRED Trainer. (Training FRED with Lazarus/FPC)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
TImage and transparency
« Reply #3 on: October 06, 2006, 06:45:58 pm »
Quote from: "Antrepolit"
I guess the Transparency isn't yet implemented.


Transparency do is implemented.

 

TinyPortal © 2005-2018