how to convert bitmap image to CIELab image?

Posted by Neal Davis on Stack Overflow See other posts from Stack Overflow or by Neal Davis
Published on 2010-05-13T23:11:23Z Indexed on 2010/05/13 23:14 UTC
Read the original article Hit count: 684

Filed under:

Hello to stackoverflow members! This is my first post but I love reading the questions and answers on this forum!

I'm using VS2008, CSharp, NET 3.5 and Windows XP Pro latest patches on this project.

I am reading in a jpeg file to a bitmap image using CSharp in the following way:

Bitmap bmp = new Bitmap("background.jpg");
Graphics g = Graphics.FromImage(bmp);

I then write some text and logos on g using various DrawString and DrawImage commands. I then want to write this bitmap to a tiff file using the command:

bmp.Save("final_artwork.tif", ImageFormat.Tiff);

I don't know what the TIFF tags in the header of the final resultant TIFF file will be when you do bmp.Save as shown above?

But what I want to produce is a TIFF image file with PHOTOMETRIC CIELab, BITSPERSAMPLE 8, SAMPLESPERPIXEL 3, FILLORDER MSB2LSB, ORIENTATION TOPLEFT, PLANARCONFIG CONTIG, and also uncompressed and singlestrip.

Im fairly certain, at least I have not found anything about Microsoft API and CIELab, I can not convert the bitmap image to CIELab photometric and the other requirements using anything from the Microsoft API or .NET 3.5 environment - someone please correct if I am wrong.

I have used libtiff in a project in the past but just to write a tiff file where the tiff image in memory was already in CIELab format and all the other requirements as noted per above. Im not certain libtiff can convert from my CSharp bitmap image, which is probably RGB photometric, to CIELab, 8 bps, and 3 spp?

Maybe I can use OpenCVImage or Emgu CV or something similiar?

So the main question is what is going to be the easiest way to get my final bitmap image as outlined above into a CIELab TIFF and also meeting the other requirements per above?

Thanks for any suggestions and code fragments you can provide?

Neal Davis

© Stack Overflow or respective owner

Related posts about c#