HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

BLPaletter 1.5

08-29-2006, 07:53 PM#1
PitzerMike
BLPaletter converts BMP, TGA and JPG images to paletted BLP images.
These often compress better than usual JPG compressed BLPs.
For example it compresses a 256x256 texture to 33kb in a map of mine.
Note that paletted blps work better with MPQ archive compression than ordinary jpg blps, so that you can only accurately compare file size after importing them into a map.
Since version 1.3 it can also create JPG compressed BLPs.
Fixed Mipmapping issues in version 1.4.
Fixed an alpha channel issue in version 1.5b.

Get the latest versoin (1.5c) here
The C++ source code is also available here
Botanic made a GUI for it, you can get it here

An older GUI made by Acaykath is also available, but I think it doesn't support the latest features that I've added. It's available here

USAGE

Code:
BLPaletter <input.tga|input.bmp|input.jpg> [<output.blp>] [<number of colors / quality>] [-j | -p] [-mipN]

Replace the N of the -mip parameter with a number between 1 and 16.
This will limit the number of generated mipmaps to a max of N.

For icons and interface textures always use -mip1 because they do not use mipmapping . Or -mip2 if you support people with really old computers who have the texture quality setting at low.

For model textures simply leave out the -mip parameter.



EXAMPLES

Code:
  BLPaletter D:\icons\BTNSomeIcon.tga -mip1
    -> Will create D:\icons\BTNSomeIcon.blp with 256 colors and 1 mipmap

  BLPaletter D:\icons\BTNBlah.bmp 128
    -> Will create D:\icons\BTNBlah.blp with 128 colors

  BLPaletter D:\icons\a.tga D:\icons\b.blp 64
    -> Will create D:\icons\b.blp with 64 colors

  BLPaletter "C:\Program Files\Something\SomeTexture.tga" Target.blp
    -> Will create Target.blp with 256 colors in the current directory (watch out: you need " when a path contains a space)

  BLPaletter C:\x.bmp C:\y.blp 85 -j
    -> Will create C:\y.blp with JPG compression and a quality of 85%

  BLPaletter ..\Textures\MountainKing.bmp -p -mip8
    -> Will create ..\Textures\MountainKing.blp with 256 colors (paletted) and 8 mipmaps at max

CHANGES IN 1.5

Fixed a bug that corrupted the alpha channel on images smaller than 128 x 128

CHANGES IN 1.4

Now auto-generates mipmaps so it works properly with textures when looking from far away
Added -mipN parameter (replace N with the number of mipmaps you wanna have, eg. -mip1 for icons)
Fixed a visual problem related to wrong mipmap offsets
Cleaned up the source code

CHANGES IN 1.3.2

It can now read jpg files too.

CHANGES IN 1.3

Added option to use jpg compression (-j vs. -p switch, -p is assumed by default)
With the -j switch on, the number of color parameter controls the quality of the output blp (values between 1 and 99 please)

CHANGES IN 1.2

Removed the 'Press any button to continue' message.

CHANGES IN 1.1

Added optional parameter to specify the number of colors (16 - 256).
Added Floyd-Steinberg-Dithering for much better looking results.

Thanks to TheProphet for a few utility functions, BlackDick and Magos
for their blp format specifications, PipeDream, the IJG for their free
Jpeg Library, Litany for providing test files.
Attached Images
File type: gifBLPaletter.gif (829 bytes)
Attached Files
File type: zipBLPPaletterGUI.zip (10.1 KB)
File type: rarBLPaletter15b_src.rar (87.9 KB)
File type: zipBLPPaletterGUI.zip (460.4 KB)
File type: rarBLPaletter15c.rar (166.4 KB)
08-29-2006, 11:27 PM#2
Vexorian
And paletted blps do not use a lossy compression.
08-30-2006, 12:12 AM#3
Tim.
Sexy, I love it!
08-30-2006, 09:17 AM#4
MeanMachine
Consider adding a tutorial on how to put this in the Path environment variable, so people can call it from any folder.(believe me, most people don't even know what Environment Varibles is)
08-30-2006, 09:26 AM#5
BertTheJasser
GJ. +Rep
08-30-2006, 04:32 PM#6
Vexorian
Quote:
Originally Posted by MeanMachine
Consider adding a tutorial on how to put this in the Path environment variable, so people can call it from any folder.(believe me, most people don't even know what Environment Varibles is)
The obvious solution is to make an interface program that calls this one. That's the linux style.
08-30-2006, 07:46 PM#7
MeanMachine
Quote:
Originally Posted by Vexorian
The obvious solution is to make an interface program that calls this one. That's the linux style.
I don't get it. Why make an interface program ? What I meant to do was add it here :

And by doing this you can call the program from EVERY folder.
08-30-2006, 07:58 PM#8
Vexorian
I mean for lame users get an interface they wouldn't need to know about that
08-30-2006, 08:13 PM#9
MeanMachine
Ah, the forotten days of DOS. Nowadays most windows users don't even know what it is because of the lame-friendly (did i say lame-friendly? i meant user-friendly) programs. Anyway, a simple interface won't hurt. Some people need 10 minutes to navigate to the correct folder in the command promt anyway.
08-31-2006, 06:48 AM#10
karukef
This is so AWESOME!

There are some images that get a better quality to size ratio with jpg (such as large lifelike textures), then there are some images that are perfect for palette, such as icons and textures with a low range of colors.

To achieve the BEST possible compression ratio, there are some tricks though. By pre-quantisizing the images to use even smaller palettes than 256, the compressor can achieve even smaller filesizes. An icon for example, that 4200 bytes after being BLPaletted would compress to 2031 bytes after I pre-reduced the number of unique colors to 32. That's over 48% of the size of the original paletted version, and 29% of the size of the original jpg/blp (at low quality setting), and it looks almost perfect!

To do this, simply open an image up in i.e Photoshop, convert it to "Indexed Color", reduce the number of colors to the smallest value you can achieve without compromising image quality (be sure to try the different dithering options) and click OK. Then, change it back to RGB mode (because that's what the BLPaletter can read) and make a paletted BLP out of it. You'll see that it compresses much better.

EDIT: Oh, and Mike, I initially considered modifying the source to allow specifying the number of colors, but then I realized you know much better how the program works and whether it would fit in. If it adds a dithering quantisizer (or does it have that?), it would probably do all this work by itself, although I'm not saying it's worth your time to implement that :)
08-31-2006, 07:52 AM#11
PitzerMike
Yeah, the quantizer class I have, already lets you specify the number of colors in the constructor. So all i need to add is an additional parameter for the number of colors and pass it to the constructor.
08-31-2006, 12:37 PM#12
PitzerMike
You can now specify the number of colors to be used and a dithering algorithm is applied to the blps so they'll look much better now.
09-01-2006, 05:19 AM#13
PipeDream
What would it take to write a tool that automatically goes through a map, finds references to appropriate images and replaces them automatically? Where would one need to search? With list file, could the images be replaced directly by giving them the former extension?
09-01-2006, 12:46 PM#14
Vexorian
This is better for an individual manual process cause the results are not always the best, some pics would have a better ratio or quality as jpeg blps.
09-01-2006, 01:31 PM#15
Chuckle_Brother
Yeah I noticed that, some images seem to bloat under this tool(namely images that are only a tga after being converted from BLP format for some reason).

At any rate, do paletted BLPs work for icons? I seem to remeber someone saying that it won't accept paletted TGAs for icons, so I hope thats not the case in this instance.