Draw shapes on images
Draw shapes on images
Hi there!
Is it possible to draw shapes on images?
I tried several ways with GDPicturePro Demo in VB2005, but did not succeed.
This is very necessary to me, if you can give me a good example (preferred in VB2005) i will buy a license.
I hope you can help me.
Is it possible to draw shapes on images?
I tried several ways with GDPicturePro Demo in VB2005, but did not succeed.
This is very necessary to me, if you can give me a good example (preferred in VB2005) i will buy a license.
I hope you can help me.
Re: Draw shapes on images
Hi,
I give you a basic way to draw 1 line and 1 rectangle on an image.
For other shapes you can get a look on the online reference guide (see Draw shapes chapter): https://www.gdpicture.com/guides/gdpicture
Best regards,
Loïc
I give you a basic way to draw 1 line and 1 rectangle on an image.
For other shapes you can get a look on the online reference guide (see Draw shapes chapter): https://www.gdpicture.com/guides/gdpicture
Code: Select all
Imaging1.CreateImageFromFile ("input.jpg")
'Draws a Semi transparent Red line using 2 pixels pen size from (0,0) to (200,200) on the native image
Call Imaging1.DrawLine(0, 0, 200, 200, 2, Imaging1.argb(125, 255, 0, 0), True)
'Draws a Semi transparent Green rectangle using 2 pixels pen size from (0,0) to (200,200) on the native image
Call Imaging1.DrawRectangle(0, 0, 200, 200, 2, Imaging1.argb(125, 0, 255, 0), True)
Imaging1.SaveAsJPEG ("output.jpg")
Loïc
Re: Draw shapes on images
Is it possible to draw shapes on an image by the interactive way?
I mean something like Paint from WinXP. You can open an image and draw shapes on it directly with your cursor,
you know?
Best regards,
Loopy
I mean something like Paint from WinXP. You can open an image and draw shapes on it directly with your cursor,
you know?
Best regards,
Loopy
Re: Draw shapes on images
Hi,
You can do that using both GdViewer & Imaging classes.
The idea is:
- Load or create an empty image into an Imaging object
- Set the loaded image into the GdViewer object
- Catch mouse events from the GdViewer to see when the used clicked and when he moved the mouse
- Using the Imaging object, draw the desired shape using coordinates raised by the events of the GdViewer object
- Refresh the viewer -> see Redraw() method
I've uploaded a vb.net freehand drawing sample which use this technic:
https://www.gdpicture.com/support/dotnetFreehand.zip
Best regards,
Loïc Carrère
You can do that using both GdViewer & Imaging classes.
The idea is:
- Load or create an empty image into an Imaging object
- Set the loaded image into the GdViewer object
Code: Select all
GdViewer1.SetNativeImage(Imaging1.GetNativeImage)
- Using the Imaging object, draw the desired shape using coordinates raised by the events of the GdViewer object
- Refresh the viewer -> see Redraw() method
I've uploaded a vb.net freehand drawing sample which use this technic:
https://www.gdpicture.com/support/dotnetFreehand.zip
Best regards,
Loïc Carrère
Re: Draw shapes on images
Hi Loic!
Thanks for your quick response!
I've made a sample for vb2005 working fine with bitmaps.
You just need a Form with a GDViewer and a GDImaging on it.
Best regards,
Loopy
Thanks for your quick response!
I've made a sample for vb2005 working fine with bitmaps.
Code: Select all
Public Class Form1
Private p As Point
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Imaging1.SetLicenseNumber("XXXXXX")
Me.GdViewer1.SetLicenseNumber("XXXXXX")
Me.GdViewer1.SetZoomFitControl()
Me.GdViewer1.ViewerQualityAuto = False
Me.GdViewer1.MouseMode = GdPicturePro5.ViewerMouseMode.MouseModeDefault
Me.GdViewer1.ViewerQuality = GdPicturePro5.ViewerQuality.ViewerQualityBilinear
Me.Imaging1.CreateImageFromFile("c:\test.bmp")
Me.Imaging1.ConvertTo24BppRGB()
Me.GdViewer1.SetNativeImage(Me.Imaging1.GetNativeImage)
End Sub
Private Sub GdViewer1_MouseDownControl1(ByVal sender As Object, ByVal e As AxGdPicturePro5.__GdViewer_MouseDownControlEvent) Handles GdViewer1.MouseDownControl
p.X = GdViewer1.GetMouseX
p.Y = GdViewer1.GetMouseY
End Sub
Private Sub GdViewer1_MouseMoveControl1(ByVal sender As Object, ByVal e As AxGdPicturePro5.__GdViewer_MouseMoveControlEvent) Handles GdViewer1.MouseMoveControl
If e.button = 1 Then
p.X = GdViewer1.GetMouseX
p.Y = GdViewer1.GetMouseY
Me.Imaging1.DrawFillEllipse(p.X - 15, p.Y - 15, 30, 30, GdPicturePro5.Colors.Aquamarine, True)
Me.GdViewer1.Redraw()
End If
End Sub
End Class
Best regards,
Loopy
Who is online
Users browsing this forum: No registered users and 2 guests