Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am creating a 64bit bitmap and wrapping it using Graphics object to draw over it. Problem is Gdiplus Color class is only 32bit(each component is byte only i.e.max 255) so how can I draw over a 64bit image using gdiplus?

Bitmap bmp(100, 100, PixelFormat64bppARGB);
Graphics g(&bmp);
//how do I draw a red line now, if i use Color(255,0,0) it comes as almost dark black red
                IIUC, a 64bpp implies a width of 16 bits for each component. However, the Color class only supports 8bit per component. One way would be to extract the pixel and set them yourself, if possible. Never have worked much with GDI so can't help more :(
– dirkgently
                Mar 7, 2009 at 12:34
                yes that seems to be only option, to draw to image and copy image buffer by scaling to 16bit, but that is what I want to avoid.
– Anurag Uniyal
                Mar 7, 2009 at 13:21
                If I had to modify buffer Why i will use gdiplus, e.g. how do you draw arial size 12 font using buffer ?
– Anurag Uniyal
                Mar 14, 2009 at 8:46

It seems Gdiplus doesn't support any 64-bit operations. An somehow easy way to still be able to use Gdiplus methods would be to split the image in two 32-bit images and operate on them seperately.

You could either split the ARGB channels into AARR and GGBB or use two 32-bit images with the lower and higher ARGB bits.

Both variants would need that you either write wrapping functions or split each call into two parts like this:

// This is what you want to do (ARGB, 16 bit per channel)
// g.DrawLine(new Pen(Color(0, 65535, 1024, 31), 1, 0, 0, 100, 100);
// AARR GGBB variant
gAARR.DrawLine(new Pen(Color(0,0,255,255), 1, 0, 0, 100, 100);
gGGBB.DrawLine(new Pen(Color(4,0,0,31), 1, 0, 0, 100, 100);
// ARGBhigh ARGBlow variant
gHigh.DrawLine(new Pen(Color(0,255,4,0), 1, 0, 0, 100, 100);
gLow.DrawLine(new Pen(Color(0,255,0,31), 1, 0, 0, 100, 100);

Note that I used Color(A,R,G,B) order here and I'm not sure about it. According to the MSDN documentation, this must be changed to Color(R,G,B,A) instead. If you won't need the alpha channel, you should prefer the highlow variant as you should still be able to use Color(R,G,B) with it.

To display or save the results, you'll need to merge the 2 buffers.

I don't think this will work because you'll screw up the anti-aliasing and transparency effects. Even if you merge "intelligently" (which is still an undefined concept...) it will still make incorrect choices for anti-aliasing. – Jason Cohen Mar 20, 2009 at 23:08 That's right, there could/will be some side-effects, but I think those can be handled (i.e. switching off anti-aliasing). It still seems to be one of the best ways to create 64-bit images without heavy efforts. – schnaader Mar 21, 2009 at 8:52 but in that case I will just draw to a 32bit transparent image and copy it again with each pixel scaled to 64bit, that is much easier. – Anurag Uniyal Mar 24, 2009 at 7:58 PixelFormat64bppARGB, and PixelFormat64bppPARGB use 16 bits per color component (channel). Microsoft Windows GDI+ version 1.0 can read 16-bits-per-channel images, but such images are converted to an 8-bits-per-channel format for processing, displaying, and saving.

thats what i am doing and question is not that, how you will draw 64bit colors over it using gdiplus graphics object – Anurag Uniyal Mar 7, 2009 at 10:19

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.