-1

I have on a Form two TImages. One is fixed (BackgroundImage - Car) and the other one is movable and is always in front (FrontImage - Tree).

When both Images overlap the FrontImage should be transparent. I tried the exact code from the answer by Remy Lebeau on the question:

How to make alpha transparent TImage in Delphi?

But the overblended image looks strange. It looks not as expected.

enter image description here enter image description here

Thanks for help

Jacks
  • 67
  • 5
  • 1
    Remy Lebeau didn't write any code in that answer. Do you mean answer by bummy? – Yuriy Afanasenkov May 29 '17 at 18:17
  • Please describe, what exactly did you do? In the link image was fully opaque at first and gets uniformly transparent. In your case I presume you have opaque tree on transparent background and want it that way? – Yuriy Afanasenkov May 29 '17 at 18:35
  • Sorry you are right: Here is the correct link: https://stackoverflow.com/questions/21638341/how-to-enable-alpha-leveling-in-timage-graphic Here I used the function called: procedure SetBMPAlpha(BMP: TBitmap; Alpha: Byte); I mentioned I have two TImages on a Scroll box. A Bitmap is assigned to each TImage component. (Car->Background->opaque, Tree->Front->Transparent) The user is now able to move one Image via Mouse Move -> Of course the images can be placed side by side or on top of each other. Therefore the user can also select the value of Alpha and change the transparency. – Jacks May 30 '17 at 07:49

1 Answers1

0

Works all right with 2 png images. First:

car with transparent background

second:

tree with transparent background

(I made printscreen, then deleted background with 'magic wand' and saved as PNG)

Just insert them in object inspector to TImage components and they would work normally (in XE2 and higher at least). No code to add transparency, it's already there.

Yuriy Afanasenkov
  • 1,440
  • 8
  • 12
  • I search for a solution which can handle Bitmaps. – Jacks May 30 '17 at 07:56
  • @Jacks what exactly do you want to achieve? Is it all front picture semi-transparent as in question you link to (so initial images are fully opaque, but you want to set alpha value to 127 for example for all pixels) or your images have alpha-channel to begin with, so they're like sprites, like non-rectangular images, so car may stand behind the tree, but the tree itself is opaque? – Yuriy Afanasenkov May 30 '17 at 09:21
  • hi, in the beginning every image is opaque. Then, the front image (tree) should move on top of back image(car) and when it does move, i should be able to change the transparency of front image (tree). I hope it is crystal clear now.. :-P – Jacks May 30 '17 at 10:53