0

I'm talking about this =>

Stream bitmaps

I'm curious, how does Windows use the individual bitmaps on that file? Does Windows have some sort of cropping tool to break them up every time it has to use them? I can't seem to find any information.

bg117
  • 354
  • 4
  • 13
  • What problem are you trying to solve? Implement a similar feature in your own code? – Yakov Galka Jan 14 '21 at 06:19
  • Yes. Exactly Yakov. – bg117 Jan 14 '21 at 10:17
  • @Nels King: Look at the following posts too: 1) [How to parse an .msstyles file?](https://stackoverflow.com/questions/291624/how-to-parse-an-msstyles-file) 2) [How to apply a .msstyles to a .NET app?](https://stackoverflow.com/q/1889024/6630084) – Jackdaw Jan 15 '21 at 08:31

1 Answers1

2

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.

Yakov Galka
  • 70,775
  • 16
  • 139
  • 220