diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 55 |
1 files changed, 51 insertions, 4 deletions
@@ -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(); //----------------------------------------------- } |