Skin optimisation tips (version1.1) by TheGreenReaper (Laurence Parry)
As I write this, there are approximately 1500 WindowBlindsskins out there, and more come out every day. Most of them look great. Most ofthem took their authors a lot of time to make. And an awful lot of them aren'tperforming as well as they could - either because the authors know how toimprove it, didn't think it made a difference, or didn't think they could dobetter. As a result, some repaint more than 20 times slower than Windowsitself. But it doesn't have to be that way.
Here are a few simple "rules of thumb" (wheredoes that phrase come from? Anyone know?) to bear in mind when making skins.
· Rule 1: Tile, tile,and tile again.
Tiling is possibly the mostimportant factor affecting skin performance. Tiling your borders rather thanstretching them will generally get you a 40% increase in performance. But itdoesn't stop there. Tile your menu bar image, too - that's another 20-30% onapps with menu bars, often overlooked. Tile your scrollbars. Tile your buttons.Tile your tabs. Tile your roof. Tile everything. You know it makessense.
·Rule 2: Never use transparency whereyou don't have to (or can fake it)
Transparency is bad, 'mmkay?It's slow, because of the need to copy bits from two places at once. I know;transparency is nice. Very nice. But is it worth it? Only you can decide. Tomake it easier, consider ways of faking transparency. For example, manyscrollbars thumbs are transparent over a blank or regularly lined background.Just put the background into the thumb images, and presto - a 'transparent'thumb image! Oh, and remember to avoid putting in "Trans=1" where youdon't need it.
In a similar vein, alphablending of buttons can be pretty, but very, very slow. If you want the blendedlook, either pre-process the images (put the button in a layer over thebackground with transparency) or try using mouseover scripts to restrictblending to when it's most effective.
·Rule 3: Computers like rectangles. Soshould you.
Yeah, I know windows areusually rectangular, and that sucks. I like rounded windows, too. But using"NoShape=1" will gain you about 30%, over and above the non-use oftransparency in your borders. This is another trade-off you have to choose foryourself. Sometimes you can pad out a nearly square window with darkened orpatterned corners. Definitely put NoShape in if you like rectangles - in whichcase you might want to consider becoming a programmer . . .
·Rule 4: Textback = Bad news
Textback images are bothstretched and blended, and appear on every titlebar. Bad news for performance(some skins run three times slower with one than without). Don't usethem.
Text outlining and (to a lesserextent) shadowing will also significantly slow the titlebar refresh, as theyeffectively cause the text to be drawn multiple times. [thanks to Neil Banfieldfor this tip]
·Rule 5: Size your bitmaps carefully.
A skinner once had a choiceof three bitmaps to use for a border. They all ended up displaying the samewindow, but the first one was two thousand pixels wide, the second was twopixels wide, and the third was two hundred pixels wide. The first bitmap was toolarge, wasting memory and disk space. The second was too small and took a lotof tiling, reducing performance (having read rule 1, he knew enough not to trystretching it). But the third was just right. Moral of the story: use thethird. Also, if your skins are actually large onscreen, they will beslower, simply because WB has to push more bits around.
·Rule 6: Cut that flab! Palletise andcompress your bitmaps.
Ok, so you've got a skin. Itperforms well. It looks good. It's ready to present to the world, right?
Wrong.
Sure, you could justzip up your skin directory and submit it . . . but you'd be reducing the chanceof people downloading it. Remember, not everyone has a high-bandwidthconnection. People are going to look at your 500k skin and think "is thisreally worth 5 minutes of my life to download?" - and then they get my200k one, and suffer agonies unimaginable. Don't let that happen to them.
Take your bitmap and reduceit to a 256-colour palette, or less if you can (for PSPers, I recommend use ofthe "Optimised Octree" with reduced colour bleeding). Most of yourbitmaps will probably use less than 256 colours anyway (you don't have to usethe same 256 colours in each), and even those that use thousands canoften be indistinguishable from their reduced equivalent.
Wallpapers and other largeimages with widely varying colours tend not to be suitable for this, but try it- you may be surprised. Then zip it - there will be a difference,and it will (almost certainly . . . <g>) be smaller than before.
·Rule 7: Short is sweet. Shorter issweeter.
You have sounds in yourskin? Great! Sounds can be that extra bonus to the user that makes thedifference between their using your skin or someone else's. But sounds filescan be big, and don't compress all that well, so before you release your skin,trim your WAVs. Simply open each one up in sound recorder, and move the sliderup until you see some action on the waveform display. Then move back a bit andselect "Delete all before this position". Then do the same to the end(except use "Delete all after this position", notbefore :-). Play it to ensure you haven't trimmed off some of the sound, thensave, and appreciate the benefit of reduced file size. As a bonus, the soundwill lag less, as it starts sooner!
If you really want to get seriousabout it, consider converting them to 22050Hz and/or mono format (via"File/Properties") - but play them before and after to ensure thesound quality doesn't degrade too much. Every little helps.
·Rule 8: Try UIS1+ - the"lite" alternative.
If your skin concept doesn'tneed all the features of UIS2, have a look at UIS1+ (also known as the"basic" skin format). UIS1+ is compatible with more problemapplications, and is all you need in some situations. However, the truth isit's not as flexible as UIS2 (which is one reason few skinners use it -along with somewhat "sparse" documentation). Have a look at it beforeyou start, though, and consider making a UIS1+ version of your skin if theregular one looks like being very 'heavy'.
Also, only UIS1+ skinscan be used with the new WB Basic, so if you don't want to miss out on anypossible users (and the ultimate in performance), go for it. Note thatthere is a difference between WB and WB Basic in this respect; with WB, themain difference when using UIS1+ is that the titlebars are less flexible, whilewith WBB a lot more functionality (checkboxes, scrollbars, etc) is not present,so if you're distributing both UIS1+ and UIS2 versions together, add therelevant sections to your UIS1+ version so that WB users get as much aspossible skinned while retaining the compatibility of UIS1+.
·Rule 9: Animation is hard work - notjust for you, but for your computer.
If you commit to creatingthirty frames of animation, be sure it's worth it. If you choose to animateyour skin, it will run slower than if you didn't. Windows wasn't exactlydesigned to support animated frames, and the faster the animation runs, themore processing power it will take. If possible, restrict the animation so itdoesn't require the repainting of multiple borders - that will speed things upa little, as well as reducing the number of frames you have to create.
If you want to be evensneakier, use scripting and moving buttons to provide animation effects thatdon't involve repainting the entire titlebar (and which look extra cool).
·Rule 10: Buttons are a bit likebarnacles - the more you have, the slower your skin goes.
Make sure you're onlyshowing buttons when you need them. Users shouldn't see max/min or help buttonswhen windows don't support maximising/minimising/context help - proper use ofvisibility codes will reduce confusion (clicking on a button that does nothingis annoying) and increase performance. They shouldn't be too big, either- trim the space you left while making them, unless you need it to make thebutton activation area bigger. Also, it's a good idea to offer the option ofhaving certain buttons visible only in "Advanced mode"(visibility=50), so that users that don't use the extra buttons (like rollup)don't have to have them.
If you don't want a buttonto be visible, either set contradictory visibility parameters so that it willnever be visible, or (less preferably) move it off the edge of the titlebar.*Don't· set Alpha=0, as WB will still draw it . . . and alpha-blend it, which results in a massive performancehit (Note: as of WB 2.2, this is no longer true, so feel free to do so ifeveryone's using that or a later version). Never blend where you don't have to.
Remember: performance isn'teverything. If you know what you're doing, you should of course feel free tobreak any of these rules (they're more like guidelines, in any case). Forexample, there is no way to get certain effects without stretching. The mostimportant thing is your artistic vision, and nothing should come in the way ofthat. Just be sure that you know what you're doing.
(Warning - advert follows- wear safety goggles)
In any case, you might wantto check your skin with SkinBench, as it's often virtually impossible to judgehow much of an effect changes to a skin have on performance by eye alone,especially if you've got a fast computer (and remember, some people out there[me] don't ;-). Try it now - freely licensed under the GPL - athttp://www.greenreaper.btinternet.co.uk/
Well, that's it - I hope youfound something here that helps you out. If you have any additions, correctionsor comments, I would be very glad to hear from you (full credit will, ofcourse, be given).
Now go forth and create askin! <G>
---
TheGreenReaper(Laurence Parry) -
"Eternity lies aheadof us, and behind. Have you drunk your fill?"