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
 dynamically draw annotation highlight/invert
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

madas

Germany
21 Posts

Posted - Oct 06 2015 :  06:58:55  Show Profile  Reply
Hi,

the annotation example is showing how to draw a highlight via mouse within the TImageEnView resp. TImageEnVect object. But how to do the same dynamically via source code (without the mouse)?

And second question:

if there is a highlight resp. annotation drawn onto the TImageEnView resp. TImageEnVect object how do i invert both the underlying image and the highlight resp. annotation?

Or is there an alternative way to do so?

thx in advance.

madas

w2m

USA
1990 Posts

Posted - Oct 06 2015 :  08:43:33  Show Profile  Reply
procedure TForm1.Button1Click(Sender: TObject);
var
  iIndex: Integer;
begin
  //Create a text object
  iIndex:= ImageEnVect1.AddNewObject;
  ImageEnVect1.ObjKind[iIndex] := iekTEXT;
  ImageEnVect1.ObjLeft[iIndex] := 100;
  ImageEnVect1.ObjTop[iIndex] := 170;
  ImageEnVect1.ObjWidth[iIndex] := 300;
  ImageEnVect1.ObjHeight[iIndex] := 50;
  ImageEnVect1.ObjPenColor[iIndex] := clBlack;
  ImageEnVect1.ObjPenWidth[iIndex] := 1;
  ImageEnVect1.ObjPenStyle[iIndex] := psClear;
  ImageEnVect1.ObjBrushStyle[iIndex] := bsClear;
  ImageEnVect1.ObjFontName[iIndex] := 'Arial';
  ImageEnVect1.ObjFontStyles[iIndex] := [fsBold];
  ImageEnVect1.ObjText[iIndex] := 'Highlighted Text Object';
  //Create a ObjBoxHighlight
  iIndex:= ImageEnVect1.AddNewObject;
  ImageEnVect1.ObjKind[)iIndex)] := iekBOX;
  ImageEnVect1.ObjLeft[)iIndex] := 96;
  ImageEnVect1.ObjTop[)iIndex] := 165;
  ImageEnVect1.ObjWidth[)iIndex] := 134;
  ImageEnVect1.ObjHeight[)iIndex] := 28;
  ImageEnVect1.ObjBoxHighlight[)iIndex] := True;
  ImageEnVect1.ObjBrushColor[)iIndex] := clYellow;
  ImageEnVect1.ObjBrushStyle[)iIndex] := bsSolid;
end;

I do not understand what you mean by invert. There are two objects, a text object and a highlight object so you can not invert them. All you can do is place one behind the other.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

madas

Germany
21 Posts

Posted - Oct 06 2015 :  09:00:39  Show Profile  Reply
Thx Bill. This code snippet is works pretty well for drawing a dynamic highlight. But after drawing the highlight and then inverting the "pic" via ImageEnView1.Proc.Negative the base image is shown inverted but the highlight still looks the same as before. So the yellow remains yellow instead of going to change to blue. Any idea why?

thx in advance.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Oct 06 2015 :  09:28:49  Show Profile  Reply
The negative filter only changes the background image, so when you apply a negative filter change the objects brush color to the color you want it to be:
procedure TForm1.Button2Click(Sender: TObject);
begin
ImageEnVect1.Proc.Negative;
// change the highlight object blue
ImageEnVect1.ObjBrushColor[1] := clBlue;
end;

Picking a suitable color is going the hard part because each images "negative" color will be different. I tried to estimate a good color by getting a color from the background image but it does not work very well:
function ContrastingColor(AColor: TColor): TColor;
{ Return the contrasting color of the passed color. }
begin
  if ((AColor and $FF) * 77 + ((AColor shr 8) and $FF) * 150 +
    ((AColor shr 16) and $FF) * 29) > 127 * 256 then
    Result := clBlack
  else
    Result := clWhite;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

w2m

USA
1990 Posts

Posted - Oct 06 2015 :  09:54:07  Show Profile  Reply
Maybe try this or with an adjustment of the contrasting color values:
function ContrastingColor(AColor: TColor): TColor;
{ Return the contrasting color of the passed color. }
begin
  if ((AColor and $FF) * 77 + ((AColor shr 8) and $FF) * 150 +
    ((AColor shr 16) and $FF) * 29) > 127 * 256 then
    Result := clRed
  else
    Result := clBlue;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ImageEnVect1.Proc.Negative;
  ImageEnVect1.ObjBrushColor[1] := ContrastingColor(ImageEnVect1.ObjBrushColor[1]);
end;


Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

madas

Germany
21 Posts

Posted - Oct 07 2015 :  01:04:33  Show Profile  Reply
Hi Bill,

yeap this functioning as well.

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