Home | About us | Overview | Software - Download | Evaluate | Order | Support | Contact | F.A.Q. | Documentations | Blog | Newsletter
Loading...

Save image in hard disk

Support for GdImageBox OCX and GdImageBox Pro ActiveX/SDK.

Save image in hard disk

Postby jadzia » Thu Mar 05, 2009 9:48 pm

Hi
I'm testing your ImageBox control & I like it, but I can't find how to save the image in the hard disk. eg. If I load an image from some URL, how can I save this image in my hard disk?
jadzia
 
Posts: 1
Joined: Thu Mar 05, 2009 9:42 pm

Re: Save image in hard disk

Postby Loïc » Fri Mar 06, 2009 4:23 pm

Hi,

The GdImageBox control is not designed to write Image.

If you are using vb and you want to save the displayed image as bmp format you can use this code:

Code: Select all
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" ( _
      lpPictDesc As PictDesc, _
      riid As Guid, _
      ByVal fPictureOwnsHandle As Long, _
      ipic As IPicture _
    ) As Long




Private Type PictDesc
    cbSizeofStruct As Long
    picType As Long
    hImage As Long
    xExt As Long
    yExt As Long
End Type

Private Type Guid
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(0 To 7) As Byte
End Type


Public Function BitmapToPicture(ByVal hBmp As Long) As IPicture

   If (hBmp = 0) Then Exit Function

   Dim NewPic As Picture, tPicConv As PictDesc, IGuid As Guid

   ' Fill PictDesc structure with necessary parts:
   With tPicConv
      .cbSizeofStruct = Len(tPicConv)
      .picType = vbPicTypeBitmap
      .hImage = hBmp
   End With

   ' Fill in IDispatch Interface ID
   With IGuid
      .Data1 = &H20400
      .Data4(0) = &HC0
      .Data4(7) = &H46
   End With

   ' Create a picture object:
   OleCreatePictureIndirect tPicConv, IGuid, True, NewPic
   
   ' Return it:
   Set BitmapToPicture = NewPic

End Function


Private Sub SaveToBitmap_Click()
  Call SavePicture(BitmapToPicture(ImageBox1.GetHBitmap), "c:\test.bmp")
End Sub



Hope this helps.

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4226
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to GdImageBox [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest

cron