How to - vb6 gdimaging to picturebox?

Discussions about image processing and document imaging.
Post Reply
mikey
Posts: 6
Joined: Sun Mar 03, 2013 5:59 pm

How to - vb6 gdimaging to picturebox?

Post by mikey » Fri Mar 08, 2013 11:00 am

In vb6 using the com object gdimaging, how do I draw to a picturebox control?

Ultimately I'm trying to transfer the image in a gdimaging object to to the .cellpicture property of a flexgrid control.

Also, is there a way to save the image In the viewer control to gif?

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

Re: How to - vb6 gdimaging to picturebox?

Post by Loïc » Fri Mar 08, 2013 12:55 pm

Something like this should do the trick:

Code: Select all

Dim hBitmap As Long = oGdPictureImaging.GetHBitmap(ImageID)
Set Picture1.Image = imgTest.FromHbitmap(hBitmap)

mikey
Posts: 6
Joined: Sun Mar 03, 2013 5:59 pm

Re: How to - vb6 gdimaging to picturebox?

Post by mikey » Fri Mar 08, 2013 5:10 pm

Loïc wrote:Something like this should do the trick:

Code: Select all

Dim hBitmap As Long = oGdPictureImaging.GetHBitmap(ImageID)
Set Picture1.Image = imgTest.FromHbitmap(hBitmap)
I don't see either of these methods with 9.4. I only see:

GetHBitmapFromGdPictureImage

and

CreateGdPictureImageFromHBitmap

Is the example your referring to from an old version?

mikey
Posts: 6
Joined: Sun Mar 03, 2013 5:59 pm

Re: How to - vb6 gdimaging to picturebox?

Post by mikey » Mon Mar 11, 2013 12:31 am

Loïc wrote:Something like this should do the trick:

Code: Select all

Dim hBitmap As Long = oGdPictureImaging.GetHBitmap(ImageID)
Set Picture1.Image = imgTest.FromHbitmap(hBitmap)
These methods dont even exist in the current version .. looks like youve copied and pasted the solution from a very old thread.

At any rate, if someone else is having the same question, I've figured it out:

Assuming you already have a GDImage object as 'ImageID':

imgHeight = m_GdPictureImaging.GetHeight(ImageID)
imgWidth = m_GdPictureImaging.GetWidth(ImageID)

Set Me.Picture1.Picture = Nothing
Me.Picture1.Height = imgHeight
Me.Picture1.Width = imgWidth

m_GdPictureImaging.DrawGdPictureImageOnHDC ImageID, Me.Picture1.hdc, 0, 0, imgWidth, imgHeight, InterpolationMode_Default
Me.Picture1.Picture = Me.Picture1.Image

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests