aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian C <cc@localhost>2025-03-02 18:48:27 -0800
committerChristian C <cc@localhost>2025-03-02 18:48:27 -0800
commitf29e592996d3a86bfe6dab4b5a8f806878cfbb9c (patch)
treec2b051ecf7c18091e110cac61730af1dfe4d8fac /src
parent0f1d49179b5ff51bc3f00e4527c4010f09440b25 (diff)
Tiff open code
Diffstat (limited to 'src')
-rw-r--r--src/main.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index f1af48d..221deb1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
}