Note that there are some explanatory texts on larger screens.

plurals
  1. PODelphi 6 : Alphablending works between sub-image and main Canvas, but not between sub-images
    primarykey
    data
    text
    <p>I have a Delphi 6 application where I have an array of TBitmaps each containing an image (sub-image) that was created by making a call to FillRect() with clWhite to flood the TBitmap's Canvas with white, followed by a call toTextOut() to print some text to the Bitmap's Canvas. </p> <p>I have a timer that updates the main Canvas, which belongs to a TImage component, with the contents of the array every Interval to reflect changes made to each sub-images X, Y coordinates since they are in motion. First I use FillRect() with clWhite to flood the main Canvas with white. To "print" the sub-images I simply iterate the array and call Alphablend() to "print" each sub-image on to the main Canvas. Each sub-image has a Z coordinate that is used to control the level of opacity. Sub-images with higher Z coordinates have a lower Alphablend() value to make them appear more transparent than those that are "up close".</p> <p>The alpha-blending works great with each individual sub-image and those that have higher coordinates do indeed appear to be more transparent than those with lower Z coordinates. However, I'm having a problem with sub-images that overlap in Z space. Alpha-blending between overlapping sub-images does not appear to work. Instead, the sub-image "behind" the overlapping sub-image is occluded by the white background belonging to the image that overlays it. What I want is for the two sub-images to overlap properly so it looks like two text strings are written on top of each other. Instead I see the front text string and everywhere the white background that comprises it's TBitmap's Canvas exists, wiping out the text string "behind" it.</p> <p>Can anyone tell me why alpha-blending is working between each individual sub-image and the main Canvas, but not between sub-images? I say between sub-images only in a temporal context and not as objects because they should all become part of the main Canvas as they print and I would expect alpha-blend to blend them properly, which is not happening.</p> <p>It's almost as if the "white" between sub-images is not being treated the same as the "white" between a sub-image and the "white" belonging to the main Canvas.</p> <p>FOLLOW-UP: In response to Andreas comment I set the PixelFormat of all sub-image TBitmap's to pf32bit. Now alpha-blending is taking place "between" sub-images. Unfortunately, the the sub-image's white areas are not being treated as a Transparent color. Instead the white background of the sub-image that is on top is being alpha-blended with the text belonging to the underlying sub-image creating a light gray frame around the sub-image on top as if it was smeared. To get the effect I want I need the white background of a sub-image to be completely ignored.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload