Winamp region.txt generator
version 4
24/12/00
by Maxim
maxim@mwos.cjb.net
maxim1 on skinz.org
http://mwos.cjb.net/win32.htm
This is a program which makes PERFECT region.txt sections for Winamp skins. All you have to do is feed it a bitmap with all the transparent bits (and nothing else) set to one colour. Because the regions generated are based on rectangles, they work the same in doublesize mode.
I've tested it on several skins; it works great. It did JafoWinampTrans 2 (JafoAmp) in under 2 seconds. That's many hours less than it took Jafo

)
To install:
Copy the .exe anywhere.
To uninstall:
Delete the .exe.
Instructions:
1. Make a mockup of the window with the transparent bits set to one colour not used anywhere else. RGB 255,0,255 is good, since that's the default transparent colour and if your skin uses it then it's probably crap.
2. Save it to a .bmp file or copy it to the clipboard.
3. Load or paste it using the buttons in the program.
4. Click on the image to choose the transparent colour if it isn't RGB 255,0,255.
5. Choose which window it's for with the combobox. This just affects which section heading is used.
6. Click Go and watch the mask window if you like.
7. Save or copy the generated data with the buttons provided.
8. Make sure it's in region.txt in the skin's folder (or zip or wsz) and reload your skin.
If something goes wrong, I'd like to hear about it.
How it works:
First, it reduces the bitmap you give it to 2 bit colour (white for transparent, black for opaque). Then it looks along the rows for a black pixel. It then looks for the biggest square it can make using this pixel as the top-left, without going into the white area. Then it extends it to the biggest possible rectangle with no white pixels in it. This rectangle is added to the region data, then turned red, and the process repeats until no black pixels remain.
It's turned red so it knows it's done those pixels, but it can make other rectangles which go over them.
History:
v2: Removed 32K data size limit; tweaked code so it can do overlapping rectangles, giving smaller data for the same effect. Both are due to hippygoth making the first skin it couldn't handle. Thanks hippy!
v3: Removed debug button left in v2 by accident. Added test button, commandline support, drag and drop support, button disabling when needed.
4: More button disabling added. Fixed BIG resource leak in v3 (turns out you should DeleteObject(HRgn) a lot. Thanks for not putting that in the CreateRectRgn() help page, Microsoft). Added image preview for Open dialogue.
Bugs:
For some reason, it has a habit of sometimes emptying the clipboard after pasting the image.
Maybe it'll mess up if you're not using 24 bit colour or greater, and the transparent colour is too close to another in the image. I dunno. 16 bit should be OK...
The test transparency doesn't work under Windowblinds.
I've got a feeling it's got a resource leak. Sorry! I'm working on it...
Other stuff:
This is formally endorsed by Just Another F***ing Observer. (That means Jafo really likes it.)
The glyphs came from Scrow's, http://members.xoom.com/scrows.
I put off writing this because of the "imminent" release of Winamp 3... since it looks like I'll be sticking with 2.x for a while, I decided to do it anyway.
I did try and do it the clever way, getting some automatic bitmap-to-region code to make the region and then decoding that. Well, all the pointers made my brain hurt so I gave up and did it the simple way, which was probably better anyway.
Check out my other Winamp proglet on the URL above, which gives you 1-click skin reloading and 2(ish)-click skin changing.
Delphi 3 source on request.
If you want to upload this on the net somewhere, please leave it as you found it - nothing removed, modified or added. That means the .exe, this .txt and the .zip.
Possible future features:
Proper region.txt support (add section, add to section, replace section, etc.)
Automatic transparent colour guessing
Skins!
Any suggestions? Let me know which of these you'd like. If you're a kickass skin maker who'd like to make the skin then I'd love to hear from you...
Disclaimer:
It's not my fault.
Bear in mind that at least one (released) version of this program was hairy enough to crash my computer. I fixed that, but I make no guarantees that it will release all the handles, objects, regions, resources, memory, figs, buns and cakes it may use.
Maxim