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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to fill a transparent area with a color?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

860 Posts

Posted - Nov 16 2021 :  17:48:56  Show Profile  Reply
A simple question: How to color-flood-fill a transparent area?

xequte

38182 Posts

Posted - Nov 17 2021 :  01:33:32  Show Profile  Reply
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
Go to Top of Page

PeterPanino

860 Posts

Posted - Nov 17 2021 :  04:44:44  Show Profile  Reply
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?
Go to Top of Page

xequte

38182 Posts

Posted - Nov 17 2021 :  15:34:55  Show Profile  Reply
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
Go to Top of Page

PeterPanino

860 Posts

Posted - Nov 18 2021 :  09:09:01  Show Profile  Reply
 
"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?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: