Question BMP conversion

stulish

Well-known member
Joined
Jun 6, 2013
Messages
61
Programming Experience
3-5
Hi guys,

I need to convert a 24bpp BMP to 8bpp does anyone have any ideas as to the best way to go around this??

Thanks

Stu
 
Last edited:
Guys,

I managed to change for format of the BMP using the code below, the bitmap is held in the variable bmp, i just used bmp.clone and just changed the format to 8bpp for the cloned bitmap, then i saved it, this seems to work, but i am not sure if it is the best way.

VB.NET:
[COLOR=blue]Dim[/COLOR] cloneRect [COLOR=blue]As[/COLOR] [COLOR=blue]New[/COLOR] [COLOR=#2b91af]Rectangle[/COLOR](0, 0, bmp.Width, bmp.Height
[COLOR=blue]Dim[/COLOR] format [COLOR=blue]As[/COLOR] [COLOR=#2b91af]PixelFormat[/COLOR] = [COLOR=#2b91af]PixelFormat[/COLOR].Format8bppIndexed
[COLOR=blue]Dim[/COLOR] clonebmp [COLOR=blue]As[/COLOR] [COLOR=#2b91af]Bitmap[/COLOR] = bmp.Clone(cloneRect, format)
clonebmp .Save(LastFileName, [COLOR=#2b91af]ImageFormat[/COLOR].Png)
bmp.Dispose()
clonebmp.Dispose()

Regards

Stu
 
Back
Top