Performing GDI directly on 8-bit DIB
This isn't a very complicated question, but I decided to come here as a last resort. What I would like to find out is if there is a way to perform GDI directly on an 8-bit DIB section. For example, is it possible to select a pen that says "palette index 20" on the DC, instead of passing a COLORREF? From what I've read in google and MSDN, you have to look up the palette entry into a COLORREF, and create the pen object (correct me if I'm mistaken). This is fine unless I have two palette entries of the same COLORREF, in which case mapping it back to 8-bit would not be able to distinguish them. Alternatively, I could work with the pixels directly, but then I'd have to write my own LineTo, Ellipse or TextOut functions.
Sorry if this sounds confusing, but basically its for a paint program which works with an 8-bit palette. If it's not possible to perform GDI directly on 8-bit, is it at least possible to distinguish two separate palette indices with the same COLORREF?
# 1 Re: Performing GDI directly on 8-bit DIB
Try GDI+
using that u can draw directly on a bitmap using all the DC functions.
See MSDN for more details
# 3 Re: Performing GDI directly on 8-bit DIB
I'm sorry, I don't really understand the purpose of the PALINDEX structure. What I would like is if, for example, palette entry 20 and 21 have the same COLORREF, they can still be drawn as separate colours. What happens now is that if I createpen(.., .., palentry(21)), and then select it into the DC to do some GDI image processing, I want it to actually write 21 to the DIB section rather than 20.
# 4 Re: Performing GDI directly on 8-bit DIB
Another way is to use ExtCreatePen:
LOGBRUSH lb;
lb.lbColor = m_crLine;
lb.lbStyle = BS_SOLID;
lb.lbHatch = 0;
HPEN hPen = ExtCreatePen (PS_GEOMETRIC | PS_ENDCAP_FLAT |PS_JOIN_MITER | m_nPenStyle, nWidth,&lb, 0, NULL);
You can use bitmap brush.
Cindy
-----------------------
For high quality flow/diagram MFC/C++ Visio Like visualization Source Code,download XD++ at:
http://www.ucancode.net
# 5 Re: Performing GDI directly on 8-bit DIB
Hmm... I'm not sure if I'm missing something, but it seems that ExtCreatePen still requires a lookup from a 8-bit entry into COLORREF. If possible I would not like to do 8-bit to 24-bit conversion at all, because the reverse process would lose some colours if two entries had the same COLORREF.