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
 dynamically draw annotation highlight/invert

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
madas Posted - Oct 06 2015 : 06:58:55
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
5   L A T E S T    R E P L I E S    (Newest First)
madas Posted - Oct 07 2015 : 01:04:33
Hi Bill,

yeap this functioning as well.

thx.
w2m Posted - Oct 06 2015 : 09:54:07
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
w2m Posted - Oct 06 2015 : 09:28:49
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
madas Posted - Oct 06 2015 : 09:00:39
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.
w2m Posted - Oct 06 2015 : 08:43:33
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