Hi Mike,
in trying to save out an image in 7.1 the error below is produced, the same image works fine in 7.0.175 as do other images that don't work in 7.1, images brought in using the import utility have the same problem.
Scott.Pearce wrote:https://service.jiwa.com.au/browse/DEV-6757 may have sorted it.
' See https://stackoverflow.com/questions/1053052/a-generic-error-occurred-in-gdi-jpeg-image-to-memorystream
' And https://stackoverflow.com/questions/336387/image-save-throws-a-gdi-exception-because-the-memory-stream-is-closed
' GDI errors may occur when saving if you don't keep the stream open that the image was created from.
'
' So, the following will fail with "A generic error occurred in GDI+" if the image was jpg and saving as png, or vice versa:
'Using image As System.Drawing.Image = JiwaApplication.Manager.ByteArrayToImage(If(Inventory.Picture Is Nothing, Inventory.SystemSettings.DefaultPicture, Inventory.Picture))
' Select Case DialogSave.FilterIndex
' Case 1
' image.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Png)
' Case 2
' image.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
' Case 3
' image.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
' Case 4
' image.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Gif)
' End Select
'End Using
' But, this works!
Using streamBitmap As New System.IO.MemoryStream(If(Inventory.Picture Is Nothing, Inventory.SystemSettings.DefaultPicture, Inventory.Picture))
Using img = System.Drawing.Image.FromStream(streamBitmap)
Select Case DialogSave.FilterIndex
Case 1
img.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Png)
Case 2
img.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
Case 3
img.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
Case 4
img.Save(DialogSave.FileName, System.Drawing.Imaging.ImageFormat.Gif)
End Select
End Using
End Using
SBarnes wrote:Hi Mike,
Thanks for letting me know, by the way I suppose there is a similar thing with the web api pictures and documents i.e. you don't know the file/media type.
SBarnes wrote:Yes I know that trick but what about documents?
Return to Technical and or Programming
Users browsing this forum: No registered users and 42 guests