ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TImageEnView : Paint on transparent pixels

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
esprd Posted - Jul 07 2025 : 13:31:37
Hello,
I have an image with 2 layers.
Layer 1 is a png black and blue, with clBlue as transparent color. The blue pixels are a kind of mask above my background, and the black darken the background (layer semi-transparent).
I want to change some "blue zones" (I have a list of pixels) into black.
But it seems that setting a color on a transparent zone has no effect.

My code :

procedure displayPicture( APictFileName, ALayerFileName : string ) ;
begin
  // Load background
  ImageEnView1.IO.LoadFromFile( APictFileName ) ;

  // Load layer
  ImageEnView1.LayersAdd(ImageEnView1.Layers[0].Kind,
                      ImageEnView1.Layers[0].PosX,
                      ImageEnView1.Layers[0].PosY,
                      ImageEnView1.Layers[0].Width,
                      ImageEnView1.Layers[0].Height) // Append a new layer


  ImageEnView1.IO.LoadFromFile( ALayerFileName ) ;

  // Set transparency
  ImageEnView1.IO.IEBitmap.SetTransparentColors( clBlue, clBlue, 0 ) ;
  ImageEnView1.Layers[1].Opacity := 0.7 ;
  
end ;


procedure UpdateDisplay( XList, YList : TIntegerlist ) ;
// Remove Pixels from "blue" transparent area, set them black, called after some user actions
var
  i : integer ;

begin

  for i := 0 to XList.Count - 1 do
    ImageEnView1.Layers[LayerIdx].Bitmap.Pixels[XList[i], YList[i]] := TColor2TRGB( clBlack ) ;

end ;

The workaround I found is to write this :

  // Reset transparency
  ImageEnView1.LayersCurrent := 1 ;
  ImageEnView1.IO.IEBitmap.SetTransparentColors( clBlue, clBlue, 255 ) ;

  for i := 0 to XList.Count - 1 do
    ImageEnView1.Layers[LayerIdx].Bitmap.Pixels[XList[i], YList[i]] := TColor2TRGB( clBlack ) ;

  ImageEnView1.IO.IEBitmap.SetTransparentColors( clBlue, clBlue, 0 ) ;
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jul 08 2025 : 21:21:38
Sorry, that should have read "Pixels_ie8" rather than just "Pixels" (because the alpha channel is a ie8g image)

But setting Alpha[ x, y ] := ...; is actually better anyway (copes also with RGBA).

Please note though that accessing Pixels directly is much slower than using ScanLines, so if performance is needed, use that instead:

http://www.imageen.com/help/TIEBitmap.Scanline.html

Nigel
Xequte Software
www.imageen.com
esprd Posted - Jul 08 2025 : 13:17:53
Ok thank you.
It's working with
ImageEnView1.Layers[LayerIdx].Bitmap.Alpha[ x, y ] := 255; // Make the pixel opaque

(building error with ImageEnView1.Layers[LayerIdx].Bitmap.AlphaChannel.Pixels[ x, y ] := 255; )

ep
xequte Posted - Jul 08 2025 : 04:17:06
Hi

Don't forget that if a pixel has been set as transparent (i.e. the pixel in the AlphaChannel has value 0) then setting the pixel in the image channel has no effect (even though the color has changed, it is still transparent).

So ensure you set the image and alpha channel pixel, e.g.

ImageEnView1.Layers[LayerIdx].Bitmap.Pixels[ x, y ] := TColor2TRGB( clBlack );
ImageEnView1.Layers[LayerIdx].Bitmap.AlphaChannel.Pixels_ie8[ x, y ] := 255;  // Make the pixel opaque

Please see:

http://www.imageen.com/help/TIEBitmap.AlphaChannel.html

Nigel
Xequte Software
www.imageen.com