For the better part of this week and past weekend, I have been learing a whole lot about surfaces in ScummVM, in order to implement beautiful 9patch borders in the MacGUI code.
As I delved deeper and deeper into the graphics code, I found out that a lot of steps had to be made in order for the 9patch to initialize and blit correctly:
- Define the alpha color in a bitmap (a bright pink).
- Load the bitmap.
- Copy the loaded bitmap into a surface.
- Apply the colorkey into the surface (previously defined alpha color).
- Pass the surface to the 9patch.
- Define the surface in which you want to blit the border.
- Blit the border.
- Convert the border into the graphics format (I still don’t know how to do this).
- Draw the border into the surface you want.
- Tell sev that you finally got his code to work, and that it works wonders.
Between each of these steps there are several hours of figuring out which PixelFormats
, Palettes
, Surfaces
and conversion functions I had to use, and several more hours in GDB and the IRC.
But, at last, besides that format conversion in step 8, 9patch is working correctly 🙂
Below are two images: The border bitmap rendered without going through the 9patch, and after passing it to the 9patch and then rendering (blit) it into surface twice as high and wide (4x size) before printing it to screen.
Edit: I just fixed a small bug, this is what it looks like now: