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
 How to fill a transparent area with a color?

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
PeterPanino Posted - Nov 16 2021 : 17:48:56
A simple question: How to color-flood-fill a transparent area?
4   L A T E S T    R E P L I E S    (Newest First)
PeterPanino Posted - Nov 18 2021 : 09:09:01
 
"I should note that CastAlpha() may not work precisely the way you want it to."


Indeed - for the uninitiated, there seem to be unpredictable results:

Here is my original image (it already contains a transparent area):



Then I selected the arrow in the middle and applied this code to create another transparent area outside of the arrow:

imgMain.Proc.CropSel(True);


This is the result:



Then finally, I applied the code to color-flood-fill the transparent area I created in the last step, by clicking inside the top left corner:

imgMain.Proc.CastAlpha( imgMain.XScr2Bmp(X), imgMain.YScr2Bmp(Y), 255, 0, clBlue );


...which resulted in this artefact:



The result seems to be correct, as the flood-filling seems to have affected only the area with the same value of alpha transparency (created implicitly by my crop action by super-imposing an already existing transparency area - is this assumption correct?).

So is it also possible to influence the flood-filling with a Tolerance Value?
xequte Posted - Nov 17 2021 : 15:34:55
Hi Peter

That is fixed in the current beta.

I should note that CastAlpha() may not work precisely the way you want it to. It flood fills based on the image color, not the alpha value. We'll consider an alpha fill type solution for a later update.

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Nov 17 2021 : 04:44:44
Hi Nigel,

thanks for the information.

If I initiate a normal color-fill (by setting ImageEnView1.MouseInteractGeneral := [miColorFill];), with the mouse hovering over an OPAQUE area, I get this mouse cursor:



... while hovering the mouse over a TRANSPARENT area, I get this mouse cursor:



Is there a built-in way to get the fill-cursor with miColorFill even when hovering the mouse over a transparent area?
xequte Posted - Nov 17 2021 : 01:33:32
Hi Peter

Please email me for an update.

You can call it as follows:

// On mouse down flood fill the area opaque with a blue fill
procedure TForm1.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ImageEnView1.Proc.CastAlpha( ImageEnView1.XScr2Bmp(X), ImageEnView1.YScr2Bmp(Y), 255, 0, clBlue );
end;


Nigel
Xequte Software
www.imageen.com