pleonex / tinke

Viewer and editor for files of NDS games
GNU General Public License v3.0
356 stars 57 forks source link

Nitro Texture Compressor for compression 4x4 blocks #31

Closed MetLob closed 7 years ago

MetLob commented 8 years ago

Hi, I implemented compression of 4x4 texels. Medium quality, but not long time.

Example of this algorythm on photo-quality image:

kodim23

texel4x4_test_1

Example of this algorythm on NDS (not-compressed Color256 8-bit indexed) image:

ht_ds_title_flat tim2_0

texel4x4_test_0

## Using

Ekona.Images.NitroTextureCompressor.Compress(byte[] bgra, uint width, uint height, bool boundaryApprox, bool onlyInterpolatedPalettes, out byte[] palette)

Where: bgra - original 32BPP data in ARGB format (first byte - B, G, R, A - last byte) width, height - size of original image boundaryApprox - using mask, which ignored inside pixels in 4x4 block, using only boundary pixels onlyInterpolatedPalettes - generates palettes only in 1 or 3 Nitro-texture-palette formats (see code of TEX0 in plugins)

WARNING If output palettes length / 4 > 0x3FFF then some pixels has invalid palette index.

pleonex commented 8 years ago

That's a huge contribution thanks! Sorry for the delay, I am quite busy these days, I will review the code as soon as possible (really interested to see how it works).

pleonex commented 8 years ago

I have been reviewing it. Awesome job! I have some comments:

MetLob commented 8 years ago

Yes. Ok. I will refactor of the code in a nearest time. Vector3 from my oldest math-core library and has Russian comments, and the Nvidia code grabbed from C++ source without refactoring.

Can I put the Vector3 class file to Ekona.Helper namespase? .

pleonex commented 8 years ago

I think that Vector3 class should be in Ekona.Images class so we can reuse it for future 3D model implementations. And don't worry about the Russian comments, I understand, Tinke has still some Spanish comments from old times that I should translate.

MetLob commented 8 years ago

I pushed with refactoring of this.