Hi,
Trying to convert 8bit indexed to 24bit I came across this:
The code below will NOT convert the indexed8 image to a 24bit image24,
(look below the code snipet)
Dim image As Bitmap
Dim image24 As Bitmap
Try
image = New Bitmap(filename)
image24 = image.Clone(New Rectangle(0, 0,
image.width,image.height), Imaging.PixelFormat.Format24bppRgb)
Catch
image24 = Nothing
End Try
but his WILL! Why does it convert the pixelformat if you just subtract
1 from the width????
Dim image As Bitmap
Dim image24 As Bitmap
Try
image = New Bitmap(filename)
image24 = image.Clone(New Rectangle(0, 0,
image.width-1,image.height), Imaging.PixelFormat.Format24bppRgb)
Catch
image24 = Nothing
End Try
Regards,
Linus
Michael Phillips, Jr. - 31 Mar 2008 15:32 GMT
The basic behavior of the Clone method is to provide you with an exact copy
of your source image.
If the rectangle to clone matches the extents of the source image, then you
get a copy with the same extents and pixel format.
If the rectangle to clone is different from the extents of the source image,
then the method must create a new image and convert it to match the
arguments which include a new pixel format.
> Hi,
>
[quoted text clipped - 33 lines]
> Regards,
> Linus
Michael C - 04 Apr 2008 05:25 GMT
> Hi,
>
> Trying to convert 8bit indexed to 24bit I came across this:
> The code below will NOT convert the indexed8 image to a 24bit image24,
> (look below the code snipet)
I think it's best to avoid using clone, it creates a copy that is somehow
linked to the original. I can't remember the exact details but I think I had
problems with disposing the images. Just create a new bitmap and use a
graphics object to draw the original onto the new one.
Michael