- Joined
- Nov 24, 2014
- Messages
- 3,162
- Reaction score
- 3,513
- Trophies
- 2
- Age
- 31
- Location
- Bologna
- Website
- rinnegatamante.it
- XP
- 4,879
- Country

Take in mind that my Bitmap framebuffer is encoded like a Bitmap file so is flipped.
Code:
void PrintScreenBitmap(int xp,int yp, Bitmap* result,int screen,int side){
if(!result) return;
u8* buffer = 0;
if (screen == 0){
if (side == 0) buffer = TopLFB;
else buffer = TopRFB;
}else if (screen == 1) buffer = BottomFB;
int x, y;
if (result->bitperpixel == 24){
for (y = 0; y < result->height; y++){
for (x = 0; x < result->width; x++){
u8 B = result->pixels[(x + (result->height - y - 1) * result->width)*3];
u8 G = result->pixels[(x + (result->height - y - 1) * result->width)*3 + 1];
u8 R = result->pixels[(x + (result->height - y - 1) * result->width)*3 + 2];
u32 color = B + G*256 + R*256*256;
DrawPixel(buffer,xp+x,yp+y,color);
}
}
}else{
for (y = 0; y < result->height; y++){
for (x = 0; x < result->width; x++){
u8 B = result->pixels[(x + (result->height - y - 1) * result->width)*4];
u8 G = result->pixels[(x + (result->height - y - 1) * result->width)*4 + 1];
u8 R = result->pixels[(x + (result->height - y - 1) * result->width)*4 + 2];
u8 A = result->pixels[(x + (result->height - y - 1) * result->width)*4 + 3];
u32 color = B + G*256 + R*256*256;
DrawAlphaPixel(buffer,xp+x,yp+y,color,A);
}
}
}
}
Code:
void DrawPixel(u8* screen, int x,int y, u32 color){
int idx = ((x)*240) + (239-(y));
screen[idx*3+0] = (color);
screen[idx*3+1] = (color) >> 8;
screen[idx*3+2] = (color) >> 16;
}








