It is intended to be used on 2D games. So it have the following characteristics:
- fast decoding
- slow encoding
- lossless
- alpha channel support
- small size, comparable to PNG, sometimes bigger, sometimes smaler, depands on the image
I skiped the Paeth filter because it's to slow for a high performance format. I had it in and tested it and it was 10 times slower than the other filters.
I plan to implement my own compression that will be much slower on compression but better on compression ratio. And the include is mostly unoptimized. The filters for the decoder are a little bit optimzed but the remain is unoptimized so with the next versions the encoder and decoder will be much faster. The decoder is allready faster than the PB internal PNG decoder. Decodes up to 2 times faster, depanding on the plattform, subsystem and image.
However it does support 2 lossless transformations of the image data for better compression. Very simple transformations, just sorting the channels. So on some images it beats PNG in size on some it's bigger than PNG because it only can store 32bit pixel. Currently there is no support for indexed colors.
It should work on every plattform supported by PB and on every subsystem supporting alpha channel. But it is not tested very much for now and it is still in beta phase.
Here is the include: http://www.GameTreasure.de/downloads/TsiInclude.zip needs PB 4.40
Comes with a XnView plugin for viewing and converting of TSI files.
With a stand alone converter (only Windows). And with a stand alone viewer (only Windows).
Just let me explain the most important procedures:
Tsi_LoadTsi2Image(FileName.s)
Similar to PB's LoadImage. Loads a TSI from a file and decodes it into a PB image.
Tsi_CatchTsi2Image(*Tsi)
Similar to PB's CatchImage. Decodes a TSI in memory to a PB image.
Tsi_LoadTsi2Sprite(FileName.s)
Similar to PB's LoadSprite. Loads a TSI from a file and decodes it into a PB sprite.
Tsi_CatchTsi2Sprite(*Tsi)
Similar to PB's CatchSprite. Decodes a TSI in memory to a PB sprite.
Tsi_BestSaveFromImage(Image.i, FileName.s)
Similar to PB's SaveImage. Encodes a PB image to a TSI and saves it to the hard disk.
Tsi_BestSaveFromSprite(Sprite.i, FileName.s)
Similar to PB's SaveSprite. Encodes a PB sprite to a TSI and saves it to the hard disk.
Tsi_BestSave2MemoryFromImage(Image.i, *TsiSize.Integer)
Similar to PB's SaveImage, but saves the TSI to memory and not to the hard disk.
Tsi_BestSave2MemoryFromSprite(Sprite.i, *TsiSize.Integer)
Similar to PB's SaveSprite, but saves the TSI to memory and not to the hard disk.
So it's easy to use. There are more procedures, that offer you more controle but you can explore the include by your self. I have commented all procedures, what they do and what they return.
Hope someone can need it.
After i have optimized the include and added my own compression i will make a animation format (TSA).
File size and decoding speed comparison TSI against PNG:
Code: Select all
File Size Comparison
3,145,728b = 3,072kb 100.00% size : raw image data
2,200,459b = 2,149kb 69.95% size : PNG saved with PureBasic
1,470,636b = 1,436kb 46.75% size : PNG saved with Gimp
1,313,207b = 1,282kb 41.73% size : PNG optimized with PNG Optimizer
1.266.965b = 1,237kb 40.27% size : TSI saved with TSI include
Decoding Speed Comparison
image on x86 Windows
68ms 100.00% time needed : PNG saved with Gimp
56ms 82.35% time needed : PNG optimized with PNG Optimizer
39ms 57.35% time needed : PNG saved with PureBasic
29ms 42.65% time needed : TSI saved with TSI include
image on x64 Windows
62ms 100.00% time needed : PNG saved with Gimp
52ms 83.87% time needed : PNG optimized with PNG Optimizer
38ms 61.29% time needed : PNG saved with PureBasic
28ms 45.16% time needed : TSI saved with TSI include
sprite with DirectX7 on x86 Windows
79ms 100.00% time needed : PNG saved with Gimp
66ms 83.54% time needed : PNG optimized with PNG Optimizer
48ms 60.76% time needed : PNG saved with PureBasic
38ms 48.10% time needed : TSI saved with TSI include
sprite with DirectX7 on x64 Windows
71ms 100.00% time needed : PNG saved with Gimp
62ms 87.32% time needed : PNG optimized with PNG Optimizer
47ms 66.20% time needed : PNG saved with PureBasic
37ms 52.11% time needed : TSI saved with TSI include
sprite with DirectX9 on x86 Windows
74ms 100.00% time needed : PNG saved with Gimp
64ms 86.49% time needed : PNG optimized with PNG Optimizer
45ms 60.81% time needed : PNG saved with PureBasic
34ms 45.95% time needed : TSI saved with TSI include
sprite with DirectX9 on x64 Windows
66ms 100.00% time needed : PNG saved with Gimp
58ms 87.88% time needed : PNG optimized with PNG Optimizer
42ms 63.64% time needed : PNG saved with PureBasic
33ms 50.00% time needed : TSI saved with TSI include