Hi all!
I need to resize a PNG image (with transparency) keeping its transparency…
I use a function like this:
[code]Function GetThumbnail(image as picture, Dimension As Integer) As Picture
dim thumb as Picture
dim ratio as double
’ Return nil if image is Nil
if image = nil then
return nil
end if
'if Dimensione=0 then
'Return image
'end if
’ Create Image Thumbnail
if image.Width>Dimension or image.Height>Dimension Then
if image.Width > image.Height then
ratio = image.Height / image.Width
thumb = New Picture(Dimension, Dimension * ratio, 32)
else
ratio = image.Width / image.Height
thumb = New Picture(Dimension * ratio, Dimension, 32)
end if
Else
thumb = New Picture(image.Width, image.Height, 32)
end if
’ Draw Thumbnail
thumb.Graphics.DrawPicture image, 0, 0, thumb.Width, thumb.Height, 0, 0, image.Width, image.Height
'Return Thumbnail
return thumb
End Function
[/code]
But it returns an image with white background. If I use this
' Draw Thumbnail
thumb.Graphics.DrawPicture image.CopyPictureWithMaskMBS, 0, 0, thumb.Width, thumb.Height, 0, 0, image.Width, image.Height
I have an image with black background.
Any help?
Many thanks!