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
–
–
–
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.
–
–
–
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.
–
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.