Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, November 27, 2007 12:34:36 PM(UTC)

rmssemp  
rmssemp

Groups: Registered
Posts: 5


I have requirment that user selects StampObject from tool bar and double clicks on the imageviewer, the stampobject is drawn automatically with predefined size. it should be able  to be deleted after it was drawn on the imageviewer. Can it be done?

 

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, November 27, 2007 11:18:53 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

If you are using LEADTOOLS v15 .Net and you want to create AnnStamp Object when you double click on the RasterImageViewer, you need to handle the DoubleClick Event of the RasterImageViewer control, and then create the AnnStampObject as follows:
+----------------+
Private Sub RasterImageViewer1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RasterImageViewer1.DoubleClick
...

Dim stamp As AnnStampObject = New AnnStampObject()
Dim pic As AnnPicture = New AnnPicture(Image.FromFile(imageFileName))
pic.TransparentMode = AnnPictureTransparentMode.None
pic.TransparentColor = Color.Black
stamp.Picture = pic
stamp.Bounds = New AnnRectangle(100, 200, 400, 600, AnnUnit.Pixel)
container.Objects.Add(stamp)

...

End Sub
+----------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Wednesday, November 28, 2007 5:53:53 AM(UTC)

rmssemp  
rmssemp

Groups: Registered
Posts: 5


Thanks,it works. I need to place the stamp object where the mouse clicked on the imageviewer. How can I convert the mouseeventargs coordinate into Imageviewer container coordinates?

 

 
#4 Posted : Wednesday, November 28, 2007 9:59:52 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

To create the AnnStamp Object on the mouse click event, and convert the mouse coordinates into Imageviewer coordinates, please use the following code:
+------------+
Private Sub RasterImageViewer1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RasterImageViewer1.MouseClick

Dim stamp As AnnStampObject = New AnnStampObject()
Dim pic As AnnPicture = New AnnPicture(Image.FromFile("c:\Sunset.jpg"))
pic.TransparentMode = AnnPictureTransparentMode.None
pic.TransparentColor = Color.Black
stamp.Picture = pic

Dim ts As New Transformer
ts.Transform = RasterImageViewer1.Transform
Dim p As PointF = ts.PointToPhysical(New PointF(e.X, e.Y))

stamp.Bounds = New AnnRectangle(p.X, p.Y, 400, 600, AnnUnit.Pixel)
AutomationAnn.Container.Objects.Add(stamp)
RasterImageViewer1.Invalidate()

End Sub
+------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Thursday, November 29, 2007 10:32:45 AM(UTC)

rmssemp  
rmssemp

Groups: Registered
Posts: 5


 

// this.imageViewer.

AnnPicture pic = new AnnPicture(System.Drawing.Image.FromFile(@"c:\checkmarkonly.bmp"));

AnnStampObject obj = new AnnStampObject();

obj.Picture = pic;

obj.Visible = true;

Transformer transform = new Transformer();

transform.Transform = this.imageViewer.Transform;

 

PointF pf = transform.PointToPhysical(new PointF(eventArgs.X, eventArgs.Y));

obj.Bounds = new AnnRectangle(pf.X, pf.Y, 60, 60, AnnUnit.Pixel);

// obj.Bounds = new AnnRectangle(new Rectangle(, new SizeF(30, 30)));

_annAutomation.Container.Objects.Add(obj);

this.imageViewer.Invalidate();

 

The above code still does not place the object where the mouse is clicked,  this code works fine without resizing the window or  scrolling the imageviwer. I

 

 
#6 Posted : Sunday, December 2, 2007 3:09:05 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

To get the actual point, please try to use the PointToLogical method instead of using the PointToPhysical method.

Please let me know if this helps.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.199 seconds.