Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
793 views
in Technique[技术] by (71.8m points)

themes - How does Windows 'break up' the pictures from the .msstyles files?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...