Hello:
Using asp.net (vb) and I dont want to use active X controls - just server
side code.
I have uploaded a gif file but I want to resample it to a smaller size like
100 by 100 and save it to a file - simple ? right ?
Upload -> Original.gif
resample
save as ->resampled.gif
I get a range of errors ranging from: A generic error occurred in GDI+.
to:
A Graphics object cannot be created from an image that has an indexed pixel
format
-----------------------------------------------------------------------------------------------------------------------------------
Dim CurrentBitMap As Image = New Bitmap(TargetWidth, TargetHeight,
CurrentImage.PixelFormat)
Dim CurrentGraphics As Graphics = Graphics.FromImage(CurrentBitMap)
CurrentGraphics.CompositingQuality = CompositingQuality.HighQuality
CurrentGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic
Dim CurrentRectangle = New Rectangle(0, 0, TargetWidth, TargetHeight)
CurrentGraphics.DrawImage(CurrentImage, CurrentRectangle)
'+++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++
' save the picture in it's original format
'+++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++
Try
Select Case UCase(Ext)
Case ".JPEG"
CurrentBitMap.Save(DestinationPhysicalPath,
System.Drawing.Imaging.ImageFormat.Jpeg)
Case ".BMP"
CurrentBitMap.Save(DestinationPhysicalPath,
System.Drawing.Imaging.ImageFormat.Bmp)
Case ".GIF"
CurrentBitMap.Save(DestinationPhysicalPath,
System.Drawing.Imaging.ImageFormat.Gif)
End Select
Catch ex As Exception
Announce("Error Attempting to convert " & SourcePhysicalPath & " to " &
DestinationPhysicalPath, Color.Yellow, Color.Red)
End Try
---------------------------------------------------------------------------------------------------------------------------------------------------------
I get this error:
A Graphics object cannot be created from an image that has an indexed pixel
format.
Line 271: Dim CurrentGraphics As Graphics =
Graphics.FromImage(CurrentBitMap)