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
 GetColorOfTopMostLeftMostPixel?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

924 Posts

Posted - May 25 2013 :  08:52:37  Show Profile  Reply
Hi! I need to use AutoCrop with images having each a different (mono-colored) border color. I.e., one image has a gray border area, another image a red border area, etc. So I must detect the color of the border area at run-time:
AutoCrop(10, GetColorOfTopMostLeftMostPixel);

But how can I define GetColorOfTopMostLeftMostPixel?

Of course, in addition of the above, a function like this would be fantastic:
GetPredominantColorOfBorderArea(BorderAreaWidth: Integer; var SuggestedToleranceValue: Integer): TColor;

Is there such a function?

PeterPanino

924 Posts

Posted - May 25 2013 :  09:09:15  Show Profile  Reply
OK, I found it myself:

ImageEnView1.Proc.AutoCrop(10, ImageEnView1.IEBitmap.Pixels[0,0]);
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 25 2013 :  09:19:28  Show Profile  Reply
Does this work for you?

function GetColorAtTopLeft(AImageEnView: TImageEnView): TColor;
{ Get the color of the pixel at position 0,0 or the pixel at the top left of the bitmap }
begin
  Result := TRGB2TColor(AImageEnView.Layers[AImageEnView.LayersCurrent].Bitmap.Pixels[0, 0]);
end;

procedure TFormDraw.Button1Click(Sender: TObject);
var
  iColorAtTopLeft: TColor;
begin
   iColorAtTopLeft := GetColorAtTopLeft(ImageEnView1);
   Panel1.Color := iColorAtTopLeft;
end;


These is no function to GetPredominantColorOfBorderArea.

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

PeterPanino

924 Posts

Posted - May 25 2013 :  10:16:38  Show Profile  Reply
Hi William, thanks for the code! But ImageEnView1.IEBitmap.Pixels[0,0] already worked for me.
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 25 2013 :  11:39:18  Show Profile  Reply
You asked:

quote:
But how can I define GetColorOfTopMostLeftMostPixel?


You did not say you already know how to do this until I had already replied.


William Miller
Go to Top of Page

PeterPanino

924 Posts

Posted - May 25 2013 :  13:31:27  Show Profile  Reply
You posted your comment 10 minutes after mine, where I wrote: "OK, I found it myself:...". So probably you overlooked it.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: