Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
798 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...