Overlay & Crop images

Example requests & Code samples for GdPicture Toolkits.
Post Reply
Oldman
Posts: 2
Joined: Thu Jul 24, 2008 1:51 pm

Overlay & Crop images

Post by Oldman » Thu Jul 24, 2008 2:07 pm

Hope this is in the correct forum---should be in Feature Request???

1) Is there any way to programmatically determine in GDPicturePro/GDViewer if an "Area Selection" is active, and if so, what are the coordinates (top, left, width, height)?

2) I need to overlay a bitmap image onto an image already on display with GDViewer (hopefully also being able to control percent of transparency and coordinates of overlay).
How to do or is this even currently possible?

3) I need to do quick crops on images, from within my program and also by user selection---so am wondering if there is a way to do so either by establishing an Area Selection, or failing that, by using something such as a VB6 "shape" control to draw an ellipse on an image, then crop away whatever is outside the Area or ellipse?

Suggestion and comments appreciated!

Oldman

Oldman
Posts: 2
Joined: Thu Jul 24, 2008 1:51 pm

Re: Overlay & Crop images

Post by Oldman » Thu Jul 24, 2008 7:15 pm

Hi Loic,

Further to my previous question #2, here is the code for current experiments, but the only result is that I get a display only of the new/overlay image---the original "image1" displayed before this is completely erased/replaced which is not what I need.

The overlay image is considerably smaller than image1 and hoped for result would have been of image1 still mostly in view but with the overlay image also within the picture---somewhere.

Public Sub DoOverlay()
Dim arPixels() As Long
If oGdPicture.LoadFromPicture(Picture1.Picture) = 0 Then
Call oGdPicture.GetPixelArray(arPixels, 0, 0, 100, 100)
Call oGdPicture.SetPixelArray(arPixels, 0, 0, 100, 100)
Call RefreshPicInfo
oGdPicture.CloseNativeImage
End If
Erase arPixels
End Sub

Again & still---help, suggestions or comments from anyone really appreciated!
Oldman

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Overlay & Crop images

Post by Loïc » Fri Jul 25, 2008 9:38 am

Hi Bill, I hope you are fine !
1) Is there any way to programmatically determine in GDPicturePro/GDViewer if an "Area Selection" is active, and if so, what are the coordinates (top, left, width, height)?
Yes:

Code: Select all

Dim nLeft As Long, nTop As Long, nWidth As Long, nHeight As Long

If GdViewer1.isRectDrawed Then 'if an area selection is active
   Call GdViewer1.GetRectValues(nLeft, nTop, nWidth, nHeight) 'catch the area coordinates
End If
2) I need to overlay a bitmap image onto an image already on display with GDViewer (hopefully also being able to control percent of transparency and coordinates of overlay).
How to do or is this even currently possible?
The DrawImageTransparency() method is your friend:
https://www.gdpicture.com/guides/gdpicture/v5/gdpictur ... rency.html

I give you a sample to draw the test.jpg image using semi transparency into the area delimited by the rectangle of selection of the GdViewer control:

Code: Select all

Dim nLeft As Long, nTop As Long, nWidth As Long, nHeight As Long
Dim nImageToDraw As Long

If GdViewer1.isRectDrawed Then
   Call GdViewer1.GetRectValues(nLeft, nTop, nWidth, nHeight)
   nImageToDraw = Imaging1.CreateImageFromFile("test.jpg")
   Imaging1.SetNativeImage (GdViewer1.GetNativeImage)
   Call Imaging1.DrawImageTransparency(nImageToDraw, 125, nLeft, nTop, nWidth, nHeight)
   Imaging1.CloseImage (nImageToDraw)
   GdViewer1.Redraw
End If
3) I need to do quick crops on images, from within my program and also by user selection---so am wondering if there is a way to do so either by establishing an Area Selection, or failing that, by using something such as a VB6 "shape" control to draw an ellipse on an image, then crop away whatever is outside the Area or ellipse?
Now, a code snippet to crop the part of the image inside the rectangle of selection of the GdViewer:

Code: Select all

Dim nLeft As Long, nTop As Long, nWidth As Long, nHeight As Long

If GdViewer1.isRectDrawed Then
   Call GdViewer1.GetRectValues(nLeft, nTop, nWidth, nHeight)
   Imaging1.SetNativeImage (GdViewer1.GetNativeImage)
   Call Imaging1.Crop(nLeft, nTop, nWidth, nHeight)
   GdViewer1.Redraw
End If

By email, you ask me a documentation of the GdPicture Pro SDK. You can find if from the reference guide area:

https://www.gdpicture.com/guides/gdpicture/

If you need a .chm send me a mail & I will try to generate one for you.

Best regards,

Loïc Carrère

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest