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
 Help with Proc.CastColor
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jwest

Brazil
67 Posts

Posted - Jul 10 2013 :  13:06:02  Show Profile  Reply
Hi,

I am drawing at runtime 18 rectangles in a IEBitMap of TImageEnVect component. Each rectangle is subdivided into 4 parts(rectangles).
I am not using Objects. I am using lineto, moveto and Rectangle methods.
I have to choose portions(rectangles) of any of them to paint at runtime.
I am trying:

procedure TForm5.ImageEnVect1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
with ImageEnVect1 do begin
BX := XScr2Bmp ( X );
BY := YScr2Bmp ( Y );
end;
RGBColor := TColor2TRGB ( clRed );
ImageEnVect1.Proc.CastColor ( BX, BY, RGBColor, 10);
end;

This works well when I click inside a rectangle part, but if I click out of a rectangle all ImageEnVect is painted.
When I click out of a rectangle, IŽd like no paint action.

I need paint only the rectangle portion clicked. Is there a way to do it without to use objects?

Thanks in advance,

Luiz

w2m

USA
1990 Posts

Posted - Jul 10 2013 :  15:32:46  Show Profile  Reply
I don't think there is a way around your problem because CastColor casts the pixel color biased on the colors around the cursor point and the tolerance value... so the key to figure this out is what colors to I want to allow filling?

If your backbround color is clWhite or some other specific color then you can get the color under the pixel with
iColorUnderCursor := TRGB2TColor(ImageEnView1.Layers[ImageEnView1.LayersCurrent].Bitmap.Pixels[BX, BY]);
if iColorUnderCursor <> clWhite then
begin
  ImageEnView1.Proc.CastColor(AX, AY, TColor2TRGB(clRed), 10);        
end
else
begin
  ShowMessage('The color being cast is white.  Can not cast white colors.');
end;

This of course will not permit filling inside the rectangle if the colors inside the rectangle is White. If the color under the mouse can be any color then this will not work of course and I do not know of a another way to proceed.

You can also draw your rectangle with a solid brush which would eliminate the need to castcolor all together. This is probably the best way to proceed, but your explanation does not describe enough of what you are trying to do to try to determine another approach.

I hope this helps.

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

jwest

Brazil
67 Posts

Posted - Jul 11 2013 :  13:50:00  Show Profile  Reply
I will try it.

Thanks,

Luiz
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: