I have some code which has been working fine, but suddenly I am getting an
error that I need help with.
Here is the code:
Dim tImg As Image
Dim inStrm, outStrm As MemoryStream
Dim bBlob() As Byte
Try
inStrm = New MemoryStream(nP hoto.TnailFile)
tImg = Image.FromStrea m(inStrm)
Dim propIDs() As Integer = tImg.PropertyId List
Dim propID As Integer
If propIDs.Length > 0 Then
' First create a "dummy" PropertyItem to use
' This is necessary because VB.NET has no "New" method to
create
' a new PropertyItem, so we are going to "hijack" an
existing one
Dim pItem As Imaging.Propert yItem =
tImg.GetPropert yItem(propIDs(0 ))
' See if we have a PropertyItem for the image width
tImg.SetPropert yItem(LoadPrope rty(pItem, &HA002, 4, width))
tImg.SetPropert yItem(LoadPrope rty(pItem, &HA003, 4, height))
End If
outStrm = New MemoryStream
tImg.Save(outSt rm, Imaging.ImageFo rmat.Jpeg)
bBlob = outStrm.ToArray
The error occurs in the tImg.Save method. The error is "A generic error
occurred in GDI+"
Essentially what I'm doing is getting an image (tImg) from a database
(nPhoto.TnailFi le), changing two property tags with new width and height
values, and saving back to the database (bBlob).
The code has been running fine for some time, but this error just popped up
and I can't seem to get around it.
Any help would be greatly appreciated.
Thanks
--
Walt
error that I need help with.
Here is the code:
Dim tImg As Image
Dim inStrm, outStrm As MemoryStream
Dim bBlob() As Byte
Try
inStrm = New MemoryStream(nP hoto.TnailFile)
tImg = Image.FromStrea m(inStrm)
Dim propIDs() As Integer = tImg.PropertyId List
Dim propID As Integer
If propIDs.Length > 0 Then
' First create a "dummy" PropertyItem to use
' This is necessary because VB.NET has no "New" method to
create
' a new PropertyItem, so we are going to "hijack" an
existing one
Dim pItem As Imaging.Propert yItem =
tImg.GetPropert yItem(propIDs(0 ))
' See if we have a PropertyItem for the image width
tImg.SetPropert yItem(LoadPrope rty(pItem, &HA002, 4, width))
tImg.SetPropert yItem(LoadPrope rty(pItem, &HA003, 4, height))
End If
outStrm = New MemoryStream
tImg.Save(outSt rm, Imaging.ImageFo rmat.Jpeg)
bBlob = outStrm.ToArray
The error occurs in the tImg.Save method. The error is "A generic error
occurred in GDI+"
Essentially what I'm doing is getting an image (tImg) from a database
(nPhoto.TnailFi le), changing two property tags with new width and height
values, and saving back to the database (bBlob).
The code has been running fine for some time, but this error just popped up
and I can't seem to get around it.
Any help would be greatly appreciated.
Thanks
--
Walt