It is a normal practice to load a bigger bitmap and then use parts of it when drawing (sometimes called an atlas). I'm not familiar with .msstyles
specifically, but assuming that you have the meta-data necessary to determine where each element is located within the bitmap, you can draw just that part using GDI functions like BitBlt
, StretchBlt
or AlphaBlend
.
These functions take the region of the source bitmap they need to blit as a parameter, rather than operating on the entire bitmap. For example, the signature for AlphaBlend
looks like this:
BOOL AlphaBlend(
HDC hdcDest,
int xoriginDest,
int yoriginDest,
int wDest,
int hDest,
HDC hdcSrc,
int xoriginSrc,
int yoriginSrc,
int wSrc,
int hSrc,
BLENDFUNCTION ftn
);
If we are to draw a 16x16 icon that's located at x=100,y=200 within the skin bitmap, we can do that as follows:
AlphaBlend(hdcDest, xoriginDest, yoriginDest, 16, 16, skinDc, 100, 200, 16, 16, blend);
Note that the actual Windows theming implementation may not do it this way, but rather split image into smaller chunks in order to reduce the memory consumption, for example.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…