]> Dogcows Code - chaz/rasterize/blobdiff - raster.c
fixes for compiling with mingw32
[chaz/rasterize] / raster.c
index 9ab926a0a30030374bd0b695c5b0e990b6fc8386..9cb12c5637f64694fdf9c2631eec65b1b36e0d9f 100644 (file)
--- a/raster.c
+++ b/raster.c
@@ -305,14 +305,15 @@ raster_t* raster_import_ppm(const char* filename)
 
     for (int y = h - 1; y >= 0; --y) {
         for (int x = 0; x < w; ++x) {
-            rgbachan_t r, g, b;
-            if (fscanf(file, "%hhu %hhu %hhu ", &r, &g, &b) != 3) {
+            uint16_t r, g, b;
+            /* mingw32 does not like %hhu conversion type */
+            if (fscanf(file, "%hu %hu %hu ", &r, &g, &b) != 3) {
                 fprintf(stderr, "Failed reading color values from %s: %s\n", filename, strerror(errno));
                 return NULL;
             }
-            rgba_t rgba = PACK(rgba, 3, r);
-            rgba = PACK(rgba, 2, g);
-            rgba = PACK(rgba, 1, b);
+            rgba_t rgba = PACK(rgba, 3, (uint8_t)r);
+            rgba = PACK(rgba, 2, (uint8_t)g);
+            rgba = PACK(rgba, 1, (uint8_t)b);
             rgba = PACK(rgba, 0, 255);
             p->pixels[y * w + x] = color_from_rgba(rgba);
         }
This page took 0.016609 seconds and 4 git commands to generate.