Loading...

SaveAsByteArray and CreateThumbnail

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

SaveAsByteArray and CreateThumbnail

Postby Nanni » Tue May 26, 2009 6:10 pm

Hi to all.

I would like to save the Thumb created with CreateThumbnail in a byte array.

With this Test code I can save the Thumb Pic to disk:

Dim ID1 As Long
Dim ID2 As Long
Dim myPic() As Byte
Dim picLen As Long
dim tmp as long

ID1 = Imaging1.CreateImageFromHwnd(GdViewer1.hwnd)
ID2 = Imaging1.CreateThumbnail(ID1, 180, 144)

'Using :
'tmp=Imaging1.SaveAsByteArray(myPic(), picLen, "png")
'I can't save the Thumb to ByteArray

Dim oPicture As StdPicture
Set oPicture = Imaging1.GetPictureFromGdPictureImage(ID2)
SavePicture oPicture, App.Path & "\Test.bmp"

'clean Up
DeletePictureObject oPicture
Set oPicture = Nothing
Call Imaging1.CloseImage(ID1)
Call Imaging1.CloseImage(ID2)

My question is:
How I can save the Thumb Pic to ByteArray and then assign again the ByteArray back to the StdPicture without save to disk?

Best Regards
Nanni
Nanni
 
Posts: 29
Joined: Thu Sep 25, 2008 6:26 pm

Save Thumbnail as ByteArray

Postby Nanni » Thu May 28, 2009 10:55 am

Hi to all

Perhaps my questions do not deserve attention or my questions are not relevant,
but I feel that my questions are often ignored.

However I think I solved the problem this way:

Dim ID1 As Long
Dim ID2 As Long
Dim myPic() As Byte
Dim picLen As Long

'get displayed image from GdViewer1
ID1 = Imaging1.CreateImageFromHwnd(GdViewer1.hwnd)
' I get also the scrollbar
'is there a way to get the displayed area from GdViewer without the scrollbars? Thanks

'create Thumb
ID2 = Imaging1.CreateThumbnail(ID1, 90, 72)

'close ID1 image
Imaging1.CloseImage(ID1)

Dim oPicture As StdPicture
Set oPicture = Imaging1.GetPictureFromGdPictureImage(ID2)

'close ID2 image
Imaging1.CloseImage(ID2)

If oPicture.handle <> 0 Then

'assign the Thumb image to imaging1
If Imaging1.CreateImageFromPicture(oPicture) > 0 Then

'Save Byte array
If Imaging1.SaveAsByteArray(myPic(), picLen, "png") = OK Then

'Create from Byte array
ID1 = Imaging1.CreateImageFromByteArray(myPic())

'clean Up Stdpicture and release memory
DeletePictureObject oPicture
Set oPicture = Nothing

Set oPicture = Imaging1.GetPictureFromGdPictureImage(ID1)

Set Image1.Picture = oPicture
Image1.Refresh
Else
MsgBox "ERROR Creating ByteArray"
End If

Else
MsgBox "ERROR CreateImageFromPicture"
End If

Else
MsgBox "ERROR Creating StdPicture"
End If

'clean Up
DeletePictureObject oPicture
Set oPicture = Nothing
Call Imaging1.CloseImage(ID1)

Best Regards
Nanni
Nanni
 
Posts: 29
Joined: Thu Sep 25, 2008 6:26 pm

Re: SaveAsByteArray and CreateThumbnail

Postby tuandv » Mon Dec 06, 2010 6:32 am

Hi, this is VB code, have you ever tried this with vbscript or javascript?
tuandv
 
Posts: 1
Joined: Fri Dec 03, 2010 11:43 am


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron