Draw object (text, line, ...) on an image
Hi,
In a IPP7 automation the macro write some values on each captured image (image name, rule, magnification).
Here's the code used to draw a rule with a text on the top left of the image.
In a IPP7 automation the macro write some values on each captured image (image name, rule, magnification).
Here's the code used to draw a rule with a text on the top left of the image.
ret = IpAnCreateObj(GO_OBJ_LINE)
ret = IpAnMove(0, 20, 85)
ret = IpAnMove(2, LongMarker, 85)
ret = IpAnSet(GO_ATTR_PENWIDTH, 4)
ret = IpAnSet(GO_ATTR_LINESTART, GO_LINEEND_LARGETICKMARK)
ret = IpAnSet(GO_ATTR_LINEEND, GO_LINEEND_LARGETICKMARK)
ret = IpAnSet(GO_ATTR_PENCOLOR, Color)'12632256
ret = IpAnCreateObj(GO_OBJ_TEXT)
ret = IpAnMove(0, 40, 15)
ret = IpAnText(TextMarker)
ret = IpAnSet(GO_ATTR_FONTSIZE, 48)
ret = IpAnSet(GO_ATTR_TEXTAUTOSIZE, 1)
Result :
https://drive.google.com/file/d/0BwLcFZkZgKhsVjZpOTFuTGpOR00/view?usp=sharing
Any help would be appreciated.
Thanks,
Martin
Result :
https://drive.google.com/file/d/0BwLcFZkZgKhsVjZpOTFuTGpOR00/view?usp=sharing
Any help would be appreciated.
Thanks,
Martin
0
Answers
-
Martin,
You could just record the creation of the calibration marker, this will give you some code like below.
PierrePublic Function ShowCalibration() As SimpleScript ShowCalibration = New SimpleScript Dim doc1 With Application.DocumentCommands.Active(ShowCalibration) .Run(doc1) End With With Measure.Calibration.SpatialCommands.ToggleCalibrationMarker(ShowCalibration) .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked .Run(doc1) End With With Measure.Calibration.SpatialCommands.ModifyOptions(ShowCalibration) .BackgroundType = MediaCy.Addins.SCalibration.modGlobals.eMarkerBackground.Shadow .BackgroundColor = System.Drawing.Color.Gray .TextSize = 12 .DAutoTextSize = 5 .BAutoTextSize = True .TextColor = System.Drawing.Color.Yellow .MarkerLength = 1R .AutoMarker = True .AutoMarkerLength = 25R .MarkerColor = System.Drawing.Color.Lime .MarkerPos = MediaCy.Addins.SCalibration.McSCalibration.enumMarkPosition.scmpTopLeft .MicrometerStep = 1 .MarkNewImages = False .ShowInActiveDataOverlay = False .BarOnTop = False .Run() End With End Function
0 -
Thanks again Pierre.
The last challenge I have is to add "free text" in the same way.
By example I have to write the image name on the bottom left of the captured picture.
Regards,
Martin0 -
Martin,
You have 3 options:- Use the Data Overlay feature (on the View tab) to configure the data you want to display on the image, then you just have to toggle the display of the data overlay.
- Create an annotation and record it, this is the code I am copying below.
- Use the lower level McGraphOverlay API, which gives you full control but is more involved.
Public Sub DrawName() Dim image1 With Application.DocumentCommands.ActiveImage(Nothing) .Run(image1) End With With Select.Annotations.ShapeCommands.Text(Nothing) .ApplyTo = Overlays.ShapeAction.NewGraphicObject .FillVisible = False .ZoomWithImage = True .Location = New System.Drawing.PointF(40,image1.Height - 70) .Size = New System.Drawing.SizeF(110,18) .AutoSize = True .TextColor = System.Drawing.Color.Yellow .Text = image1.DisplayName .Run(image1) End With End Sub
0 -
thanks again Pierre0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions