How to save an image with MS Access ?

Discussions about image processing and document imaging.
Post Reply
dominic
Posts: 3
Joined: Sun Jun 03, 2007 1:46 am

How to save an image with MS Access ?

Post by 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

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

Post by 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

dominic
Posts: 3
Joined: Sun Jun 03, 2007 1:46 am

Save as problem in access

Post by 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

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

Post by 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

dominic
Posts: 3
Joined: Sun Jun 03, 2007 1:46 am

Question

Post by 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?

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

Post by 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

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests