Browse Source

reversed x and y scan directions

Iver 1 month ago
parent
commit
58138535ea
2 changed files with 2 additions and 9 deletions
  1. BIN
      builds/libpitmap.so
  2. 2 9
      src/library/main.c

BIN
builds/libpitmap.so


+ 2 - 9
src/library/main.c

@@ -74,18 +74,16 @@ PM_image* PM_load_bitmap(){
 
 
     int row_size = ceil((float)(bits_per_pixel * image_width) / (32)) * 4;
     int row_size = ceil((float)(bits_per_pixel * image_width) / (32)) * 4;
 
 
-    printf("%d\n", row_size);
-
     if (bits_per_pixel < 8) {
     if (bits_per_pixel < 8) {
         printf("under 8 bits per pixel not implemented");
         printf("under 8 bits per pixel not implemented");
     
     
         return NULL;
         return NULL;
     }
     }
 
 
-    for (int y = image_height - 1; y >= 0; y--){ // starting at the bottom of the image becuase data is backwards
+    for (uint32_t y = 0; y < image_height; y++){
         int current_byte_of_row = 0;
         int current_byte_of_row = 0;
 
 
-        for (int x = 0; x < image_width; x++){
+        for (int x = image_width - 1; x >= 0; x--){ // starting reversed becuase image data is backwards
             switch (bits_per_pixel){
             switch (bits_per_pixel){
                 case (32): { // RGBA 1 byte each
                 case (32): { // RGBA 1 byte each
                     image->frame_buffer[y * image_height + x] = (uint32_t)((uint8_t)get_1() << 24 | (uint8_t)get_1() << 16 | (uint8_t)get_1() << 8 | (uint8_t)get_1());
                     image->frame_buffer[y * image_height + x] = (uint32_t)((uint8_t)get_1() << 24 | (uint8_t)get_1() << 16 | (uint8_t)get_1() << 8 | (uint8_t)get_1());
@@ -132,11 +130,6 @@ PM_image* PM_load_bitmap(){
         skip(row_size - current_byte_of_row);
         skip(row_size - current_byte_of_row);
     }
     }
 
 
-    printf("\n\ndone\n");
-
-
-    write_tga("./image.tga", image);
-
     return image;
     return image;
 }
 }