diff options
author | Christian C <cc@localhost> | 2025-03-02 18:48:27 -0800 |
---|---|---|
committer | Christian C <cc@localhost> | 2025-03-02 18:48:27 -0800 |
commit | f29e592996d3a86bfe6dab4b5a8f806878cfbb9c (patch) | |
tree | c2b051ecf7c18091e110cac61730af1dfe4d8fac /src/main.c | |
parent | 0f1d49179b5ff51bc3f00e4527c4010f09440b25 (diff) |
Tiff open code
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -3,6 +3,8 @@ #include <raylib.h> +#include <tiffio.h> + #include <lib/lib.h> int main() @@ -11,6 +13,30 @@ int main() const char* gui_title = "Image Manip - Useful for segmentations!"; InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, gui_title); + TIFF *tif = TIFFOpen("./data/test.tif", "r"); + if (!tif) { + fprintf(stderr, "Failed to open TIFF file\n"); + return 1; + } + + uint32_t width, height; + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); + + uint32_t* raster = (uint32_t*)_TIFFmalloc(width*height*sizeof(uint32_t)); + if (raster == NULL) { + fprintf(stderr, "Memory allocation error\n"); + TIFFClose(tif); + return 1; + } + + if (!TIFFReadRGBAImage(tif, width, height, raster, 0)) { + fprintf(stderr, "Failed to read TIFF image\n"); + _TIFFfree(raster); + TIFFClose(tif); + return 1; + } + SetTargetFPS(60); Camera2D camera = { 0 }; camera.zoom = 1.0f; @@ -28,6 +54,9 @@ int main() //----------------------------------------------- } + _TIFFfree(raster); + TIFFClose(tif); + CloseWindow(); return 0; } |