[FIX] Error loading bitmaps when w!=h
This commit is contained in:
30
mini.cpp
30
mini.cpp
@@ -165,33 +165,33 @@ uint8_t loadsurf(const char* filename) {
|
|||||||
switch(header.bpp) {
|
switch(header.bpp) {
|
||||||
case 1:
|
case 1:
|
||||||
for (int x=0; x<(surfaces[i].w/8); ++x) {
|
for (int x=0; x<(surfaces[i].w/8); ++x) {
|
||||||
CURRENT(x*8 , surfaces[i].w-1-y) = buffer[x+y*(surfaces[i].w/8)] >> 7;
|
CURRENT(x*8 , surfaces[i].h-1-y) = buffer[x+y*(surfaces[i].w/8)] >> 7;
|
||||||
CURRENT(x*8+1, surfaces[i].w-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 6 ) & 0x1;
|
CURRENT(x*8+1, surfaces[i].h-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 6 ) & 0x1;
|
||||||
CURRENT(x*8+2, surfaces[i].w-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 5 ) & 0x1;
|
CURRENT(x*8+2, surfaces[i].h-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 5 ) & 0x1;
|
||||||
CURRENT(x*8+3, surfaces[i].w-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 4 ) & 0x1;
|
CURRENT(x*8+3, surfaces[i].h-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 4 ) & 0x1;
|
||||||
CURRENT(x*8+4, surfaces[i].w-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 3 ) & 0x1;
|
CURRENT(x*8+4, surfaces[i].h-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 3 ) & 0x1;
|
||||||
CURRENT(x*8+5, surfaces[i].w-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 2 ) & 0x1;
|
CURRENT(x*8+5, surfaces[i].h-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 2 ) & 0x1;
|
||||||
CURRENT(x*8+6, surfaces[i].w-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 1 ) & 0x1;
|
CURRENT(x*8+6, surfaces[i].h-1-y) = ( buffer[x+y*(surfaces[i].w/8)] >> 1 ) & 0x1;
|
||||||
CURRENT(x*8+7, surfaces[i].w-1-y) = buffer[x+y*(surfaces[i].w/8)] & 0x1;
|
CURRENT(x*8+7, surfaces[i].h-1-y) = buffer[x+y*(surfaces[i].w/8)] & 0x1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
for (int x=0; x<(surfaces[i].w/4); ++x) {
|
for (int x=0; x<(surfaces[i].w/4); ++x) {
|
||||||
CURRENT(x*4 , surfaces[i].w-1-y) = buffer[x+y*(surfaces[i].w/4)] >> 6;
|
CURRENT(x*4 , surfaces[i].h-1-y) = buffer[x+y*(surfaces[i].w/4)] >> 6;
|
||||||
CURRENT(x*4+1, surfaces[i].w-1-y) = ( buffer[x+y*(surfaces[i].w/4)] >> 4 ) & 0x3;
|
CURRENT(x*4+1, surfaces[i].h-1-y) = ( buffer[x+y*(surfaces[i].w/4)] >> 4 ) & 0x3;
|
||||||
CURRENT(x*4+2, surfaces[i].w-1-y) = ( buffer[x+y*(surfaces[i].w/4)] >> 2 ) & 0x3;
|
CURRENT(x*4+2, surfaces[i].h-1-y) = ( buffer[x+y*(surfaces[i].w/4)] >> 2 ) & 0x3;
|
||||||
CURRENT(x*4+3, surfaces[i].w-1-y) = buffer[x+y*(surfaces[i].w/4)] & 0x3;
|
CURRENT(x*4+3, surfaces[i].h-1-y) = buffer[x+y*(surfaces[i].w/4)] & 0x3;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
for (int x=0; x<(surfaces[i].w/2); ++x) {
|
for (int x=0; x<(surfaces[i].w/2); ++x) {
|
||||||
CURRENT(x*2, surfaces[i].w-1-y) = buffer[x+y*(surfaces[i].w/2)] >> 4;
|
CURRENT(x*2, surfaces[i].h-1-y) = buffer[x+y*(surfaces[i].w/2)] >> 4;
|
||||||
CURRENT(x*2+1, surfaces[i].w-1-y) = buffer[x+y*(surfaces[i].w/2)] & 0xf;
|
CURRENT(x*2+1, surfaces[i].h-1-y) = buffer[x+y*(surfaces[i].w/2)] & 0xf;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
for (int x=0; x<(surfaces[i].w); ++x) {
|
for (int x=0; x<(surfaces[i].w); ++x) {
|
||||||
CURRENT(x, surfaces[i].w-1-y) = buffer[x+y*(surfaces[i].w)];
|
CURRENT(x, surfaces[i].h-1-y) = buffer[x+y*(surfaces[i].w)];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user