crnlib
This is a port from crunch/crnlib, the license could be found at the end of file.
Feel free to open a issue about usage and/or features to make it better to use. Now (Jan 2021) it still works well for my specific usage.
Usage
use *;
let sample = "samples/test.crn";
let mut file = open.expect;
let mut buffer = Vecnew;
let header = parse.expect;
let tables = header.get_table.expect;
let level0 = header.unpack_level.expect;
// level0 contains DXT encoded image content, which could be read by image
use ImageDecoder;
let = header.get_level_info.expect;
let variant = match header.format ;
let decoder = new.expect;
let mut raw = vec!;
let color_type = decoder.color_type;
decoder.read_image.expect;
let f = create.expect;
let encoder = new;
encoder.encode.expect;
Document of Table
- Any table contains 2 huffman tree
- 14 bit of max_symbol_count of second tree
- "symbol_count" of first temporary tree, the symbol was reordered as
[ShortZero, LongZero, ShortRepeat, LongRepeat, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15, 16]. - temporary one has Key
0..=16as well asShortZero, LongZero, ShortRepeat, LongRepeatwhich come with a parameter with3, 7, 2, 6bits. - the depth array (of length max_symbol_count) of second one is encoded using first one.
- A huffman tree is stored using symbol_depth.
- symbol_depth means length of code in bits.
- the Code is assign to Key from small depth to large, then follow the ord of Key.
License of Crunch
crunch/crnlib uses a modified ZLIB license. Specifically, it's the same as zlib except that
public credits for using the library are *required*.
Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software.
2. If you use this software in a product, this acknowledgment in the product
documentation or credits is required:
"Crunch Library Copyright (c) 2010-2016 Richard Geldreich, Jr."
3. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
4. This notice may not be removed or altered from any source distribution.