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
 SelectColors help

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
AndyColmes Posted - Jan 04 2014 : 02:11:25
I use SelectColors to select a known color using CreateRGB. I would like to know how to do the following:

1. Either replace the selected color with another color

2. Or, Copy and paste to create another bitmap of the selected color

Thank you in advance.
4   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Jan 12 2014 : 07:42:51
The "pink" colors are many shades of "pink", so CastColorRange does not work well in this situation. You should try to use CastColor with various tolerance values to replace the colors. By using undo you can reset and try another tolderance value until you get the colors converted that are acceptable. I find that it is difficult to fill a gradient with a color because there are so many shades. It would be nice if ImageEn had a method that could replace all shades of "pink" to a different color... something like ReplaceAllShadesOfAColor(AColor: TColor; ANewColor: TColor), but there is no such function. The best you can do at the moment is to use CastColor unless someone knows how to get the first shade of "pink" and the last shade of "pink". Unfortunately I do not how to get the starting and ending shade.

I have a small demo that shows how to use castcolor to replace the "pink" colors. Send me your email and I'll send you the demo.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
AndyColmes Posted - Jan 11 2014 : 21:13:57
Hello William, how do I use CastColorRange with the sample image if I want to change the pink color to white to match the background white? I can't seem to be able to determine the color range for the pink. Thanks for your help.

AndyColmes Posted - Jan 05 2014 : 03:51:26
Hello William,

Thank you for the code. I will give it a try.
w2m Posted - Jan 04 2014 : 07:06:09
Did you try CastColorRange or CastColor?


TImageEnProc.CastColorRange

Declaration

procedure CastColorRange(BeginColor, EndColor, CastColor: TRGB);

Description
Use this method to force all colors included in the range BeginColor and EndColor to be equal to CastColor.

Example
// Force to black all gray levels from 50 to 100
var
  BeginColor, EndColor, CastColor:TRGB;
begin
  BeginColor:=CreateRGB(50,50,50);
  EndColor:=CreateRGB(100,100,100);
  CastColor:=CreateRGB(0,0,0);
  ImageEnView1.Proc.CastColorRange(BeginColor,EndColor,CastColor);
end;


TImageEnProc.CastColor

Declaration

procedure CastColor(x, y: Integer; newColor:TRGB; tolerance: Integer);

Description

Performs a flood-fill starting at x, y coordinates. newColor is the color used to paint.
tolerance specifies the maximum difference from the starting pixel (0=no tolerance, pixels must be equals).

Example

// assuming X,Y = mouse coordinates, paints points to red
ImageEnView1.Proc.CastColor(ImageEnView1.XScr2Bmp(X), ImageEnView1.Yscr2Bmp(Y), CreateRGB(255,0,0), 0);


William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html