spread palette. You need to go in and re-set the transparent colour
"Lori McDonald" <lori@bwedd.com> wrote in message
news:e0960ffd.0402121012.62104bc7@posting.google.com...
> I have code that resizes JPG well... actually I developed it from a
> newsgroup post here:
>
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=eB7LHhuODHA.4024%40tk2msftngp13.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3DeB7LHhuODHA.4024%2540tk2msftngp13.phx.gbl
>
> However, when I try to resize a transparent GIF (and save it as a JPG)
> I end up with a file that shows black. I expect it to show the
> transparent color (which is purple in this case). That is what
> happens if I save the GIF as a JPG without resizing it.
>
> Any suggestions?
>
> Here is my code:
>
> Shared Function ResizeImage(ByVal imgPhoto As Image, ByVal intWidth As
> Integer, ByVal intHeight As Integer) As Image
> Dim newImg As Image
> Dim ms As New MemoryStream()
> Dim graphic As Graphics
> Dim rect As New Rectangle(0, 0, intWidth, intHeight)
> Dim iformat As System.Drawing.Imaging.ImageFormat
>
> If imgPhoto.PixelFormat =
> System.Drawing.Imaging.PixelFormat.Format1bppIndexed _
> Or imgPhoto.PixelFormat =
> System.Drawing.Imaging.PixelFormat.Format4bppIndexed _
> Or imgPhoto.PixelFormat =
> System.Drawing.Imaging.PixelFormat.Format8bppIndexed _
> Or imgPhoto.PixelFormat =
> System.Drawing.Imaging.PixelFormat.Undefined _
> Or imgPhoto.PixelFormat =
> System.Drawing.Imaging.PixelFormat.DontCare _
> Or imgPhoto.PixelFormat =
> System.Drawing.Imaging.PixelFormat.Format16bppArgb1555 _
> Or imgPhoto.PixelFormat =
> System.Drawing.Imaging.PixelFormat.Format16bppGrayScale Then
> 'Because a graphics object cannot be created from an
> Indexed Pixel Format (GIF)
> 'we will use a different method to resize it
> newImg = New Bitmap(intWidth, intHeight,
> PixelFormat.Format32bppArgb)
> iformat = ImageFormat.Jpeg
> Else
> newImg = New Bitmap(intWidth, intHeight,
> imgPhoto.PixelFormat)
> iformat = imgPhoto.RawFormat
> End If
>
> 'Scale image using system.drawing
> graphic = Graphics.FromImage(newImg)
> graphic.CompositingQuality() =
> System.Drawing.Drawing2D.CompositingQuality.HighQuality
> graphic.SmoothingMode =
> Drawing.Drawing2D.SmoothingMode.HighQuality
> graphic.InterpolationMode =
> System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
> graphic.DrawImage(imgPhoto, rect)
> 'Save new image
> newImg.Save(ms, iformat)
> graphic.Dispose()
>
> Return newImg
>
> End Function
>
> Thanks,
> Lori