Loading...

How to save an image with MS Access ?

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

How to save an image with MS Access ?

Postby dominic » Sun Jun 03, 2007 6:11 pm

This is the code that I use on a save button in an acces form with the active x. I want to save the picture after a modification:

Private Sub SaveImage_Click()
Dim sImageString As String
Dim strLinkedDoc

strLinkedDoc = Me.Linked_Doc
MsgBox strLinkedDoc
Select Case right(Me.Linked_Doc, 3)

Case "gif"
sImageString = oGdPicture.SaveAsString("gif")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsGif (strLinkedDoc)
Case "bmp"
sImageString = oGdPicture.SaveAsString("bmp")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsBmp (strLinkedDoc)
Case "jpg"
MsgBox "jpg"
sImageString = oGdPicture.SaveAsString("jpg")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsJpeg (strLinkedDoc)
Case "peg"
sImageString = oGdPicture.SaveAsString("jpg")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsJpeg (strLinkedDoc)
Case "tif"
sImageString = oGdPicture.SaveAsString("tif")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsTiff (strLinkedDoc)
Case "wmf"
sImageString = oGdPicture.SaveAsString("jpg")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsJpeg (strLinkedDoc)
MsgBox "Converti en Jpeg"

Case Else

MsgBox "Format d'image invalide"
OgdViewer.ClosePicture

End Select


End Sub

Would you tell me why it doesn’t work? Also why Is it telling me that I use a not registered version when on the load event of my form I have enter the proper serial number
dominic
 
Posts: 3
Joined: Sun Jun 03, 2007 1:46 am

Postby Loïc » Sun Jun 03, 2007 8:01 pm

Would you tell me why it doesn’t work?


I need more precisions.

1 - What you want exactly to do ?

2 - What is the return code of each methods you are using:

I suggest you to replace this kind of code:

Code: Select all
Case "gif"
sImageString = oGdPicture.SaveAsString("gif")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsGif (strLinkedDoc)



By this one:

Code: Select all
Dim nState as long

Case "gif"
sImageString = oGdPicture.SaveAsString("gif")

nState = oGdPicture.GetState()
If nState = 0 Then
   OgdViewer.ClosePicture
   nStat = oGdPicture.LoadFromString (sImageString)
   If nState = 0 Then
      nState =  oGdPicture.SaveAsGif (strLinkedDoc)
      If nState <> 0 then
         Msgbox "Can't Save as GIF, error code no: " & Str(nState)
      End if
   Else
      Msgbox "Can't load from string, error code no: " & Str(nState)
   End If
Else
   Msgbox "Can't save as string, error code no: " & Str(nState)
End if




Also why Is it telling me that I use a not registered version when on the load event of my form I have enter the proper serial number



What is the code you are using to unlock the component ? (Please replace your license key by XXX)


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

Save as problem in access

Postby dominic » Sun Jun 03, 2007 11:29 pm

I have several button on a form that does different thing like rotate, greyscale... I am not able to save my modification after a change. I tried your code but I had to change getstate for getstat and remove the bracket after the getstate. I get error code 1 on saveasstring
dominic
 
Posts: 3
Joined: Sun Jun 03, 2007 1:46 am

Postby Loïc » Mon Jun 04, 2007 3:22 pm

OK I think your problem come from the code you are using before calling the SaveImage_Click() button.

You have to check that the oGdPicture object have a good native image.

You can do it like that into your SaveImage_Click() method


Code: Select all
Private Sub SaveImage_Click()

If oGdPicture.SaveAsJpeg("c:\removeme.jpg") = 0 Then
   msgbox "OK"
Else
  MsgBox "Error: " & str(oGdPicture.GetStat)
End If
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Question

Postby dominic » Tue Jun 05, 2007 4:02 am

Try that last piece of code but not saving... Let me rephrase my question. Lets say that you would want to add a save button on your access demo form (form1). What would be the code for that button?
dominic
 
Posts: 3
Joined: Sun Jun 03, 2007 1:46 am

Postby Loïc » Tue Jun 05, 2007 10:00 am

Like that:


Code: Select all
Dim oGdPicture2 As New GdpicturePro.cGdPicture
oGdPicture.SetNativeImage(GdViewer.GetNativeImage)
oGdPicture.SaveAsJpeg("c:\removeme.jpg")

Set oGdPicture2 = Nothing




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


Return to GdPicture [Pro] ActiveX

Who is online

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

cron