Tuesday, 15 February 2011

c# - convert 32bpp Bitmap to 16bpp (Grayscale) -



c# - convert 32bpp Bitmap to 16bpp (Grayscale) -

this question has reply here:

how convert pixel formats? 32bpprgb 16bpp grayscale in c# 2 answers

i'm creating bitmap in c# image object.

the bitmap 32bpp, how can transform 16bpp?

bitmap image_bmp; system.drawing.image tmp = (system.drawing.image)img.renderimage(0); //renderimage creates object of tyoe system.drawing.image image_bmp = new bitmap(tmp);

if run quick search on google can find number of first-class color grayscale formulas. take next from wikipedia example:

y' = 0.2126 r' + 0.7152 g' + 0.0722 b'

with in mind general process in .net going be:

create new image of right dimensions 16bpp grayscale use "lockbits" on original image , new image , loop on each pixel unlock both images, save new image file

rather going these steps farther found few other questions stack , around web delve details more. see:

set individual pixels in .net format16bppgrayscale image how convert pixel formats? 32bpprgb 16bpp grayscale in c# http://social.msdn.microsoft.com/forums/vstudio/en-us/10252c05-c4b6-49dc-b2a3-4c1396e2c3ab/writing-a-16bit-grayscale-image?forum=csharpgeneral

best of luck!

note - i'm assuming using gdi+. steps similar windows imaging component (wic) classes , syntax radically different.

c# bitmap pixel

No comments:

Post a Comment