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
 TImageEnVect - Magnify a section of image
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

stwizard

USA
39 Posts

Posted - May 02 2014 :  07:21:38  Show Profile  Reply
Greetings All,

ImageEn v5.0.5
Delphi XE5

I use a TImageEnVect component to display a 8.5" x 11" document (The entire document). Doing so of course makes the font small on the entire document making it readable, but just barely.

In the lower left corner of all documents if a unique identification code. Is it possible to add a rectangular magnifier in the lower left corner of the image of a size I specify to magnify this portion of the document? I want to be able to turn this feature on or off, but will automatically display if turned on.

Any sample code would be wonderful.

Thanks,
Mike

w2m

USA
1990 Posts

Posted - May 02 2014 :  08:12:28  Show Profile  Reply
The only way to magnify a portion of the image is with a magnify layer. See the Layers Demo.
procedure TForm1.MagnifyLayer1Click(Sender: TObject);
{ Create a magnify layer. }
{ Note: This only works if LayersSync is False }
var
  iLayer: Integer;
begin
  with ImageEnView1 do
  begin
    iLayer := LayersAdd;    { Make the layers box visible and selectable and draw a box around the layer }
Note: If you do not want the layer to be selectable or moveable because it will always be at the same position then comment the next 3 lines or set all 3 to False. } 
    CurrentLayer.VisibleBox := True;
    CurrentLayer.Selectable := True;
    LayersDrawBox := True;
    { Give the layer a name }
    Layers[iLayer].name := 'Magnifier';
    { Set the layers dimensions }
    Layers[iLayer].Width := 320;
    Layers[iLayer].Height := 240;
    { Set the layers position }
    Layers[iLayer].PosX := 0;
    Layers[iLayer].PosY := Layers[0].Bitmap.Height - Layers[iLayer].Height;
    CurrentLayer.Magnify.Source := iemBackgroundLayer;
    { Enable a magnified layer }
    CurrentLayer.Magnify.Enabled := MagnifiedEnabled1.EditValue;
    { Set the Magnification }
    CurrentLayer.Magnify.Rate := Magnification1.EditValue;
    { Set magnify style }
    CurrentLayer.Magnify.Style := iemRectangle;
    { Optional }
    { Allow selecting layers }
    SelectLayers1.Down := True;
    MouseInteract := [miMoveLayers, miResizeLayers];
    Gestures.Pan.Enabled := False;
    Gestures.Zoom.Enabled := False;
    Gestures.LayerRotate.Enabled := False;
    Gestures.LayerMove.Enabled := True;
    Update;
  end;
end;


To turn the magnifier off then remove the layer:
{ Remove the layer from ImageEnView }
{ Get the layer to be deleted }
  iLayer := ImageEnView1.LayersCurrent;
  ImageEnView1.LayersRemove(iLayer);
  ImageEnView1.Update;

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

stwizard

USA
39 Posts

Posted - May 05 2014 :  04:53:48  Show Profile  Reply
Thank you for the quick reply.

I have tested many variants of your code in my project and it just does not work as expected for my purposes, so I cam up with another idea and will ask it in a separate thread.

Thanks,
Mike
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: