Getting RGB values for each pixel from a 24bpp Bitmap for conversion to GBA format in C

后端 未结 8 1515
南方客
南方客 2020-12-16 08:52

I want to read the RGB values for each pixel from a .bmp file, so I can convert the bmp into a format suitable for GBA (GameBoy Advance).

I

8条回答
  •  春和景丽
    2020-12-16 09:41

    If the BMP file has a palette then the below code should work:

      FILE *inFile, *outFile;
      inFile = fopen("C:/in.bmp", "rb");
      Rgb Palette[256];
      if ( inFile ) {
        // Bypass headers
        fseek(inFile, sizeof(BmpHeader) + sizeof(BmpImageInfo), SEEK_SET);
        // Load the whole palette
        fread(Palette, sizeof(Palette), 1, inFile);
        fclose(inFile);
      }
    

提交回复
热议问题