Compare commits

..

10 commits
v0.1.1 ... main

Author SHA1 Message Date
G2
62ffdeba3c
Update SQP logo image 2024-08-27 01:21:07 -05:00
e0d118dbcd Moved test images 2024-08-26 03:41:32 -05:00
b1c2b0881c Added some test images 2024-08-26 03:37:38 -05:00
df249d02dc Merge branch 'main' of https://github.com/Dangoware/dpf 2024-08-26 00:43:55 -05:00
96fcc9c16a Fixed clippy complaints 2024-08-26 00:43:48 -05:00
G2
1b4933a45d
Update README.md 2024-08-24 03:44:52 -05:00
G2
3ce09575dc
Update README.md 2024-08-24 03:04:36 -05:00
G2
ea893e64d4
Update README.md, added some example images 2024-08-24 03:03:47 -05:00
G2
0d7e82e771
Update README.md 2024-08-23 16:13:12 -05:00
d720fa60b0 Bumped version, 0.1.1 2024-08-06 15:45:48 -05:00
16 changed files with 27 additions and 8 deletions

View file

@ -6,7 +6,7 @@ The squishiest image format!
repository = "https://github.com/Dangoware/sqp"
license = "MIT OR Apache-2.0"
authors = ["G2 <ke0bhogsg@gmail.com>"]
version = "0.1.0"
version = "0.1.1"
edition = "2021"
categories = ["encoding", "compression", "graphics", "multimedia::images", "multimedia::encoding"]

View file

@ -1,8 +1,10 @@
<p align="center">
<img width="400px" src="https://github.com/user-attachments/assets/98f94c1c-ed6f-49a3-b906-c328035d981e">
<img title="SQP" alt="SQP Logo" width="500px" src="https://github.com/user-attachments/assets/cf2fd7f4-f825-4bb4-9427-1b7181be4639">
</p>
# SQP
[![Lib.rs Version](https://img.shields.io/crates/v/sqp?style=for-the-badge&logo=rust&label=lib.rs&color=%23a68bfc)](https://lib.rs/crates/sqp)
[![docs.rs](https://img.shields.io/docsrs/cross_usb?style=for-the-badge)](https://docs.rs/sqp/)
**SQP** (**SQ**uishy **P**icture Format) is an image format designed
for ease of implementation and learning about compression and image formats
while attaining a relatively good compression ratio. The general idea is to
@ -19,6 +21,7 @@ speeds.
- Support for various color formats (RGBA, Grayscale, etc.)
- Decent compression ratios, the lossless compression can often beat PNG
especially on images with transparency
- Lossy alpha compression!
- Relatively simple
- Squishy! 🍡
@ -30,3 +33,14 @@ speeds.
- Decoder-based frame interpolation
- Floating point color
- Metadata?
## Examples
All examples are at 30% quality in both JPEG and SQP.
| Original | JPEG | SQP |
|----------|--------------|-------------|
| <img width="300px" src="https://github.com/user-attachments/assets/e4f7b620-4cf5-407d-851b-800c52c8a14d"> | <img width="300px" src="https://github.com/user-attachments/assets/84691e8c-2f73-4a1d-b979-0863066b159f"> | <img width="300px" src="https://github.com/user-attachments/assets/ccaa8770-b641-437f-80d1-3658f94c2e21"> |
| <img width="300px" src="https://github.com/user-attachments/assets/f0056e3b-8988-4d0d-88bf-bc73ac5b8be0"> | <img width="300px" src="https://github.com/user-attachments/assets/400c4072-ba69-45d7-8051-46a4e2867c7f"> | <img width="300px" src="https://github.com/user-attachments/assets/c4c84f64-7564-433a-a922-17da472578d9"> |
Images obtained from the following source:
[https://r0k.us/graphics/kodak/](https://r0k.us/graphics/kodak/)

View file

@ -100,6 +100,9 @@ pub fn idct(input: &[f32], width: usize, height: usize) -> Vec<u8> {
///
/// Instead of using this, use the [`quantization_matrix`] function to
/// get a quantization matrix corresponding to the image quality value.
///
/// TODO: In the future, it would be cool to figure out how to generate a
/// quantization matrix of any size.
const BASE_QUANTIZATION_MATRIX: [u16; 64] = [
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,

View file

@ -18,8 +18,10 @@
//! let width = 2;
//! let height = 2;
//! let bitmap = vec![
//! 255, 255, 255, 255, 0, 255, 0, 128,
//! 255, 255, 255, 255, 0, 255, 0, 128
//! 0xFF, 0xFF, 0xFF, 0xFF,
//! 0x00, 0x80, 0x00, 0x80,
//! 0xFF, 0xFF, 0xFF, 0xFF,
//! 0x00, 0x80, 0x00, 0x80,
//! ];
//!
//! // Create a 2×2 image in memory. Nothing is compressed or encoded

View file

@ -58,9 +58,9 @@ pub fn add_rows(width: u32, height: u32, color_format: ColorFormat, data: &[u8])
// Interleave the offset alpha into the RGB bytes
data[rgb_index..rgb_index + width as usize * (color_format.pbc() - 1)]
.chunks(color_format.pbc() - 1)
.zip(data[alpha_index..alpha_index + width as usize].into_iter())
.zip(data[alpha_index..alpha_index + width as usize].iter())
.flat_map(|(a, b)| {
a.into_iter().chain(vec![b])
a.iter().chain(vec![b])
})
.copied()
.collect()

View file

@ -264,5 +264,5 @@ fn decode_varint_stream(stream: &[u8]) -> Vec<i16> {
pub fn open<P: AsRef<Path>>(path: P) -> Result<SquishyPicture, Error> {
let input = File::open(path)?;
Ok(SquishyPicture::decode(input)?)
SquishyPicture::decode(input)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

BIN
src/test_images/kodim03.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
src/test_images/kodim23.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

BIN
test_images/dpf_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

BIN
test_images/kodim03.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
test_images/kodim23.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
test_images/sqp_text.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

BIN
test_images/test-lossy.sqp Normal file

Binary file not shown.