diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c8071ea --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +allegro_qoi +Copyright © 2025 Canithesis Interactive + +Uses code from qoi.h +Copyright (c) 2022 Dominic Szablewski + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/allegro_qoi.c b/allegro_qoi.c index 251d3be..725820b 100644 --- a/allegro_qoi.c +++ b/allegro_qoi.c @@ -36,7 +36,7 @@ ALLEGRO_BITMAP* _al_load_qoi_f(ALLEGRO_FILE* file, int flags) { ALLEGRO_BITMAP* bmp = al_create_bitmap(meta.width, meta.height); ALLEGRO_LOCKED_REGION* lock = al_lock_bitmap( bmp, fmt, - ALLEGRO_LOCK_READWRITE + ALLEGRO_LOCK_WRITEONLY ); al_set_new_bitmap_flags(oldflags); if (!lock) return NULL; diff --git a/sample.c b/sample.c index c0f3b50..716c07a 100644 --- a/sample.c +++ b/sample.c @@ -1,6 +1,6 @@ // This program simply loads a QOI file into Allegro // as a texture and then dumps the texture data as a PNG. -// Take notice of lines 26 and 27. You only need to initialize +// Take notice of lines 32 and 33. You only need to initialize // the QOI plugin (this registers the function hooks that Allegro // will use whenever you want to I/O on a filename ending in .qoi) // @@ -21,10 +21,17 @@ int main(int argc, char **argv) { printf("Usage: sample \n"); return 0; } + al_init(); al_init_image_addon(); al_init_qoi(); + + // We don't want to multiply color by alpha because + // we're writing back to another image here, in a + // game you would leave this flag unset. + al_set_new_bitmap_flags(ALLEGRO_NO_PREMULTIPLIED_ALPHA); ALLEGRO_BITMAP* bmp = al_load_bitmap(argv[1]); + al_save_bitmap("out.png", bmp); return 0; } diff --git a/sample_AlphaMultiply.qoi b/sample_AlphaMultiply.qoi new file mode 100644 index 0000000..c2ec713 Binary files /dev/null and b/sample_AlphaMultiply.qoi differ