User1107894578 posted
Hello all, I'm having a very weird issue with some imaging code.
Here is what I'm trying to do.
I have an InfoPath form where my users attach pictures in the form. I run (try to run) code that takes the image and resize it and replace that image with an optimized one. So far all I have is this.
Private
Sub Form1_Load(ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles
MyBase.Load
Dim retval
As Image
retval = Image.FromFile("C:/Temp/ali.gif")
Dim mystring
As
String
mystring = Me.ImageToBase64String(retval, retval.RawFormat)
End
Sub
Public
Function ImageFromBase64String(ByVal base64
As
String)
As Image
Dim memory
As
New IO.MemoryStream(Convert.FromBase64String(base64))
Dim result
As Image = Image.FromStream(memory)
memory.Close()
Return result
End
Function
Public
Function ImageToBase64String(ByVal myImage
As Image,
ByVal format
As Imaging.ImageFormat)
As
String
Dim memory2
As
New IO.MemoryStream()
myImage.Save(memory2, myImage.RawFormat)
Dim base64
As
String
base64 = Convert.ToBase64String(memory2.ToArray())
memory2.Close()
Return base64
End
Function
This code works great and error free when in a windows application. But when I put this same exact code in InfoPath, I get the dreaded "Generic Error in GDI+" Why is this? Thanks!!!!