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
 Area that should be white - Microsoft Picture Manager

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
Waheed Posted - Aug 30 2021 : 13:13:42
There is a feature in Microsoft Picture Manager 2010 where it replaces an color from the selected pixel/s color to white.

The tool looks like this, when I press on the button the screen cursor changes to a cross-hair


Then I click on the picture (here is a sample of the before)



(and the sample after)



How can I do that in ImageEn?
Here is my efforts which didn't work as expected, colors inside enclosed areas are not made white:

procedure TfrMain.btnCastColorClick(Sender: TObject);
begin
   CastColorOn := True;
   Screen.Cursor := crCross;
end;

procedure TfrMain.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
   fMouseDownX := X;
   fMouseDownY := Y;
end;

procedure TfrMain.Image1Click(Sender: TObject);
begin
   if CastColorOn then begin
      // it took a long time for the operation to complete compared to Microsoft method
      Image1.Proc.CastColor(Image1.XScr2Bmp(fMouseDownX), Image1.Yscr2Bmp(fMouseDownY), CreateRGB(255, 255, 255), 10); 
      CastColorOn := False;
      Screen.Cursor := crDefault;
   end;
end;



Here is the sample image.
attach/Waheed/202183013381_sample.zip
647.81 KB
-----------------
3 Monitors
Windows 10
Delphi 6,2007 and 10.2
ImageEn v.10.0.1

2   L A T E S T    R E P L I E S    (Newest First)
Waheed Posted - Aug 30 2021 : 22:49:36
Great. Thanks.
xequte Posted - Aug 30 2021 : 18:29:52
Hi Waheed

CastColor performs a flood fill. You want to use CastColorRange which processes all pixels in the image.


procedure TForm1.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
const
  Tolerance = 10;
var
  clickColor, fromRGB, toRGB: TRGB;
begin
  // When the user clicks the image turn all image pixels of a similar color to white
  if fColorCasting then
  begin
    clickColor := ImageEnView1.IEBitmap.Pixels[ ImageEnView1.XScr2Bmp(x), ImageEnView1.Yscr2Bmp(y) ];

    fromRGB := CreateRGB( imax( 0, clickColor.r - Tolerance ),
                          imax( 0, clickColor.g - Tolerance ),
                          imax( 0, clickColor.B - Tolerance ));
    toRGB   := CreateRGB( imin( 255, clickColor.r + Tolerance ),
                          imin( 255, clickColor.g + Tolerance ),
                          imin( 255, clickColor.B + Tolerance ));

    ImageEnView1.Proc.CastColorRange( fromRGB, toRGB, CreateRGB(255, 255, 255));
  end;
end;


Nigel
Xequte Software
www.imageen.com