summaryrefslogtreecommitdiff
path: root/examples/text.c
diff options
context:
space:
mode:
authorLevent Kaya <42411502+lvntky@users.noreply.github.com>2024-11-27 01:33:45 +0300
committerGitHub <noreply@github.com>2024-11-27 01:33:45 +0300
commitc7b78ebc52e789f0c4d21e3351169871c2b4143f (patch)
tree487fd817ccc0e1ac6c6c5112366553bb53ee2096 /examples/text.c
parent449ea58099de8fac62aae389b4ea2808a6ef66f3 (diff)
parent19ae0e7c82275831531429c3cfabd6810c311185 (diff)
Merge pull request #9 from dario-loi/master
[FEATURE] Filled and Outlined Circle
Diffstat (limited to 'examples/text.c')
-rw-r--r--examples/text.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/examples/text.c b/examples/text.c
index 7cbf3ff..9003e3c 100644
--- a/examples/text.c
+++ b/examples/text.c
@@ -16,35 +16,35 @@ int save_framebuffer_as_ppm(fbgl_t *fb, const char *filename)
}
// Write PPM header (P6 format - binary RGB)
- fprintf(fp, "P6\n%zu %zu\n255\n", fb->width, fb->height);
+ fprintf(fp, "P6\n%u %u\n255\n", fb->width, fb->height);
- // Allocate buffer for pixel data
- uint8_t *pixel_buffer = malloc(fb->width * fb->height * 3);
- if (!pixel_buffer) {
+ // Allocate buffer for pixel data
+ uint8_t* pixel_buffer = malloc(fb->width * fb->height * 3);
+ if (!pixel_buffer) {
perror("Memory allocation error");
fclose(fp);
return -1;
}
// Convert framebuffer to RGB
- for (size_t y = 0; y < fb->height; y++) {
- for (size_t x = 0; x < fb->width; x++) {
- uint32_t pixel = fb->pixels[y * fb->width + x];
-
- // Extract RGB components (assuming 32-bit ARGB or RGB)
- uint8_t r = (pixel >> 16) & 0xFF;
- uint8_t g = (pixel >> 8) & 0xFF;
- uint8_t b = pixel & 0xFF;
-
- // Store in buffer for PPM
- pixel_buffer[(y * fb->width + x) * 3] = r;
- pixel_buffer[(y * fb->width + x) * 3 + 1] = g;
- pixel_buffer[(y * fb->width + x) * 3 + 2] = b;
- }
- }
-
- // Write pixel data
- fwrite(pixel_buffer, 1, fb->width * fb->height * 3, fp);
+ for (int32_t y = 0; y < fb->height; y++) {
+ for (int32_t x = 0; x < fb->width; x++) {
+ uint32_t pixel = fb->pixels[y * fb->width + x];
+
+ // Extract RGB components (assuming 32-bit ARGB or RGB)
+ uint8_t r = (pixel >> 16) & 0xFF;
+ uint8_t g = (pixel >> 8) & 0xFF;
+ uint8_t b = pixel & 0xFF;
+
+ // Store in buffer for PPM
+ pixel_buffer[(y * fb->width + x) * 3] = r;
+ pixel_buffer[(y * fb->width + x) * 3 + 1] = g;
+ pixel_buffer[(y * fb->width + x) * 3 + 2] = b;
+ }
+ }
+
+ // Write pixel data
+ fwrite(pixel_buffer, 1, fb->width * fb->height * 3, fp);
// Cleanup
free(pixel_buffer);