1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#include <stdio.h>
#include <stdlib.h>
#include <raylib.h>
#include <tiffio.h>
#include <lib/lib.h>
int main()
{
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
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;
while (!WindowShouldClose()) {
//-----------------------------------------------
//-DRAWING---------------------------------------
//-----------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode2D(camera);
EndMode2D();
DrawText("Image Manip", 0, 0, 0, DARKGRAY);
EndDrawing();
//-----------------------------------------------
}
_TIFFfree(raster);
TIFFClose(tif);
CloseWindow();
return 0;
}
|