gfx_texture* gfx_tex_load_mem_bmp(unsigned char *ptrMemBmp) { unsigned char *temp = (unsigned char *) ptrMemBmp; BMPHeader0 *Bmpinfo0 = (BMPHeader0 *) (temp); BMP_Headers *Bmpinfo = (BMP_Headers*) (temp+14); unsigned char *gfx = temp+Bmpinfo0->ImageStart; unsigned short *gfx2 = (unsigned short*) (temp+Bmpinfo0->ImageStart);//66); // For 16 bit mode ... int r, g, b; short tempx, tempy; short lx = Bmpinfo->Width; short ly = Bmpinfo->Height; unsigned short Bits = Bmpinfo->BitsperPixel; gfx_texture* tempTexture = (gfx_texture*)malloc(sizeof(gfx_texture) + (lx * ly * 2)); if(tempTexture == NULL) { return NULL; } tempTexture->address = (void*)((uintptr_t)tempTexture + sizeof(gfx_texture)); tempTexture->width = lx; tempTexture->height = ly; uint16_t* tempTexPtr = tempTexture->address; int i = 0; if (Bits > 16) { // For 24 and 32 bits for (tempy = ly-1; tempy > -1; tempy--){ for (tempx = 0; tempx < lx; tempx++){ b = (gfx[ i ] ); i++; g = (gfx[ i ] ); i++; r = (gfx[ i ] ); i++; if (Bits == 32) i++; // We pass the alpha bit tempTexPtr[tempx + ((tempy) * lx)] = gfx_color_rgb(r, g, b); } while(i&3) i++; // Padding.... } } if (Bits == 16) { for (tempy = ly-1; tempy > -1; tempy--){ for (tempx = 0; tempx < lx; tempx++) { b = *gfx2 ; g = (*gfx2>>5) ; r = (*gfx2>>10); tempTexPtr[tempx + ((tempy) * lx)] = gfx_color_rgb(r, g, b); gfx2++; // Go to next pixel } int temp = (int) gfx2; while(temp&3) temp++; // Padding.... gfx2 = (unsigned short *) temp; } } if (Bits == 8 ) { // look for palette data if present // unsigned char *colormap = temp+14+Bmpinfo->SizeofHeader; for (tempy = ly-1; tempy > -1; tempy--){ for (tempx = 0; tempx < lx; tempx++){ b = ((colormap[(gfx[ i ]<<2)+0])); g = ((colormap[(gfx[ i ]<<2)+1])); r = ((colormap[(gfx[ i ]<<2)+2])); tempTexPtr[tempx + ((tempy) * lx)] = gfx_color_rgb(r, g, b); i++; } } } return tempTexture;}
#ifdef __GNUC__ #define __PACKED __attribute__ ((__packed__))#else #define __PACKED #pragma pack(1)#endiftypedef struct { unsigned char Id[2]; // ? __PACKED unsigned int Length; __PACKED unsigned short Nothing1, Nothing2; // ? __PACKED unsigned int ImageStart; // Offset of start of image} BMPHeader0;typedef struct { __PACKED unsigned int SizeofHeader; // 40 __PACKED unsigned int Width, Height; __PACKED unsigned short Colorplanes; // Usually 1 __PACKED unsigned short BitsperPixel; //1, 2, 4, 8, 16, 24, 32 __PACKED unsigned int Compression; // 0 for none, 1... __PACKED unsigned int SizeofData; // Not reliable __PACKED unsigned int WidthperMeter, HeightperMeter; // Don't care __PACKED unsigned int NColors, ImportantColors; // Number of colors used, important colors ?} BMP_Headers;extern gfx_texture* gfx_tex_load_mem_bmp(unsigned char *ptrMemBmp);
Hum Kalisiin ... As you can see, you are in the development part of the forum, so it's for developers, not for dingoo final users ...And developers know what to do with that