2015-08-02 12:12:44 +00:00
|
|
|
#ifdef QB64_BACKSLASH_FILESYSTEM
|
2022-05-06 04:02:21 +00:00
|
|
|
# include "src\\EasyBMP.cpp"
|
|
|
|
#else
|
|
|
|
# include "src/EasyBMP.cpp"
|
2015-08-02 12:12:44 +00:00
|
|
|
#endif
|
|
|
|
|
2022-05-06 04:02:21 +00:00
|
|
|
uint8 *image_decode_bmp(uint8 *content, int32 bytes, int32 *result, int32 *x, int32 *y) {
|
|
|
|
// Result:bit 1=Success,bit 2=32bit[BGRA]
|
|
|
|
*result = 0;
|
|
|
|
|
|
|
|
BMP bm;
|
|
|
|
|
|
|
|
if (!bm.ReadFromMemory((char *)content, bytes)) {
|
2021-01-21 01:24:25 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2022-05-06 04:02:21 +00:00
|
|
|
|
|
|
|
int32 h, w;
|
|
|
|
h = bm.TellHeight();
|
|
|
|
w = bm.TellWidth();
|
|
|
|
|
2021-01-21 01:24:25 +00:00
|
|
|
uint8 *out;
|
2022-05-06 04:02:21 +00:00
|
|
|
out = (uint8 *)malloc(h * w * 4);
|
|
|
|
|
|
|
|
uint8 *o;
|
|
|
|
int32 x2, y2;
|
|
|
|
o = out;
|
|
|
|
for (y2 = 0; y2 < h; y2++) {
|
|
|
|
for (x2 = 0; x2 < w; x2++) {
|
|
|
|
*o = bm(x2, y2)->Blue;
|
|
|
|
o++;
|
|
|
|
*o = bm(x2, y2)->Green;
|
|
|
|
o++;
|
|
|
|
*o = bm(x2, y2)->Red;
|
|
|
|
o++;
|
|
|
|
*o = 255;
|
|
|
|
o++;
|
2021-01-21 01:24:25 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-06 04:02:21 +00:00
|
|
|
|
|
|
|
*result = 1 + 2;
|
|
|
|
*x = w;
|
|
|
|
*y = h;
|
2021-01-21 01:24:25 +00:00
|
|
|
return out;
|
2015-08-02 12:12:44 +00:00
|
|
|
}
|