Skip to content

EPSILON0-dev/qoi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quite Okay Image (QOI) Library

Welcome to the Quite Okay Image (QOI) library! This is a simple and fast C implementation of the QOI image format — a cool lossless image compression format that’s easy to use and super quick to encode and decode.

This library was written by me as a fun challenge in around 4 hours -- Time well spent!

Overview

The magic happens in qoi.c and qoi.h. These files let you load and save QOI images with support for both RGB and RGBA pixel formats.

Features

  • Lossless image compression and decompression with the QOI format.
  • Works with images that have 3 channels (RGB) or 4 channels (RGBA).
  • Simple and straightforward API for loading and saving images.
  • Minimal dependencies — just plain old C.

API Reference

This header file defines the main data structures and functions:

  • QOI_EResult: Enum for error and status codes you might get back.
  • QOI_ImageStruct: Holds your image data, dimensions, channels, and colorspace info.
  • Functions:
    • qoi_load_from_file(const char *path, QOI_ImageStruct *image): Loads a QOI image from a file.
    • qoi_store_to_file(const char *path, QOI_ImageStruct *image): Saves your image data to a QOI file.
    • qoi_image_free(QOI_ImageStruct image): Frees the memory used by the image pixels.

How to Use

  1. Include qoi.h in your project.
  2. Call qoi_load_from_file to load a QOI image.
  3. Work with the raw pixel data via the pixels pointer in QOI_ImageStruct.
  4. Modify or use the image data however you want.
  5. Save your changes with qoi_store_to_file.
  6. When you’re done, free the pixel data with qoi_image_free.

Example

#include "qoi.h"
#include <stdio.h>

int main() {
    QOI_ImageStruct image;
    if (qoi_load_from_file("input.qoi", &image) != QOI_OK) {
        printf("Oops! Couldn’t load the image.\n");
        return 1;
    }

    // Do your image magic here

    if (qoi_store_to_file("output.qoi", &image) != QOI_OK) {
        printf("Oops! Couldn’t save the image.\n");
    }

    qoi_image_free(image);
    return 0;
}

Plans for the Future

  • Add load/store to memory functionality
  • Add an ability to set custom callbacks for FS access

License

This project is under the MIT License. Software provided AS IS, without any warranties.

References

About

Fast & simple C library for QOI image format

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors