aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian C <cc@localhost>2025-03-04 12:46:54 -0800
committerChristian C <cc@localhost>2025-03-04 12:46:54 -0800
commit4f20bd35a875df96d92ea2114011a3d38fc3672a (patch)
tree917212610c5cef9c018bf6038c10f7f77f863e1d
parent3333fb49ff1e2993d8f895fe46a2b407866140fa (diff)
Overlay tag starting
-rw-r--r--src/main.c55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 02697aa..4226980 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include <raylib.h>
@@ -7,6 +8,9 @@
#include <lib/lib.h>
+#define TAG 50839
+#define OFFSET 16
+
int main()
{
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
@@ -18,10 +22,30 @@ int main()
fprintf(stderr, "Failed to open TIFF file\n");
return 1;
}
+ /*
+ else {
+ int dircount = 0;
+ do {
+ dircount++;
+ TIFFPrintDirectory(tif, stdout, TIFFPRINT_NONE);
+ } while (TIFFReadDirectory(tif));
+ printf("%d directories in\n", dircount);
+ return 0;
+ }
+ */
uint32_t width, height;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
+ uint32_t count;
+ void* buffer;
+ TIFFGetField(tif, TAG, &count, &buffer);
+ printf("%d\n", count);
+ for (size_t index = 0; index < 10; index++) {
+ printf("%2X ", ((uint8_t *)buffer)[index]);
+ }
+ printf("\n");
+
uint32_t* raster = (uint32_t*)_TIFFmalloc(width*height*sizeof(uint32_t));
if (raster == NULL) {
@@ -37,6 +61,21 @@ int main()
return 1;
}
+ struct timespec ts;
+ char buff[100];
+ timespec_get(&ts, TIME_UTC);
+ strftime(buff, sizeof buff, "%D %T", gmtime(&ts.tv_sec));
+ printf("Current time: %s.%09ld UTC\n", buff, ts.tv_nsec);
+
+ uint32_t out = 0;
+ for (size_t y = 0; y < height; y++) {
+ for (size_t x = 0; x < width; x++) {
+ out += x * y - out ^ 0xF;
+ }
+ }
+ strftime(buff, sizeof buff, "%D %T", gmtime(&ts.tv_sec));
+ printf("Current time: %s.%09ld UTC\n", buff, ts.tv_nsec);
+
Image RaylibImage;
RaylibImage.data = raster;
RaylibImage.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
@@ -46,9 +85,9 @@ int main()
Texture2D RaylibTexture = LoadTextureFromImage(RaylibImage);
Rectangle sourceRec = { 0.0f, 0.0f, (float)width, (float)height };
- Rectangle destRec = { 0.0f, 0.0f, (float)80, (float)80 };
+ Rectangle destRec = { 0.0f, 0.0f, (float)SCREEN_WIDTH, (float)(SCREEN_HEIGHT-OFFSET) };
- Vector2 origin = { (float)0, (float)-10 };
+ Vector2 origin = { (float)0, (float)-OFFSET };
SetTargetFPS(60);
Camera2D camera = { 0 };
@@ -62,8 +101,16 @@ int main()
ClearBackground(RAYWHITE);
BeginMode2D(camera);
EndMode2D();
- DrawText("Image Manip", 0, 0, 10, DARKGRAY);
- DrawTexturePro(RaylibTexture, sourceRec, destRec, origin, (float)0, RAYWHITE);
+ DrawText("Image Manip", 0, 0, OFFSET, DARKGRAY);
+ DrawTexturePro(RaylibTexture, sourceRec, destRec, origin, (float)0,
+ RAYWHITE);
+ uint32_t x = 0x49, y = 0x4A;
+ uint32_t dx = 0x69 - x, dy = 0x6E - y;
+ x = (SCREEN_WIDTH*x)/width;
+ y = SCREEN_HEIGHT-((SCREEN_HEIGHT-OFFSET)*y)/height;
+ dx = (SCREEN_WIDTH*dx)/width;
+ dy = SCREEN_HEIGHT-((SCREEN_HEIGHT-OFFSET)*dy)/height;
+ DrawRectangleGradientH(x, y, dx, dy, MAROON, GOLD);
EndDrawing();
//-----------------------------------------------
}