Changed filetest to use new bitmap draw method.
This commit is contained in:
@@ -130,46 +130,10 @@ SCREEN_STRUCT* get_screen_filetest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void image_test() {
|
static void image_test() {
|
||||||
//Source: http://stackoverflow.com/a/17040962/2606757
|
|
||||||
|
|
||||||
FILE_HANDLE* file = filesystem_file_open("cpu.bmp");
|
|
||||||
if(file==NULL) {
|
if(!tft_draw_bitmap_file_unscaled(250,170,"cpu.bmp")) {
|
||||||
tft_print_line(10,180,BLUE,TRANSPARENT,0,"Could not open cpu.bmp");
|
tft_print_line(10,180,BLUE,TRANSPARENT,0,"Could not open cpu.bmp");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
tft_draw_rectangle(250-1,170-1,250-1+64,170-1+64,BLACK);
|
||||||
|
|
||||||
unsigned char info[54];
|
|
||||||
if(filesystem_file_read(file,info,54)!=F_OK) {
|
|
||||||
tft_print_line(10,180,BLUE,TRANSPARENT,0,"Could not read header of cpu.bmp");
|
|
||||||
filesystem_file_close(file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract image height and width from header
|
|
||||||
int width = *(int*)&info[18];
|
|
||||||
int height = *(int*)&info[22];
|
|
||||||
|
|
||||||
filesystem_file_seek(file,*(int*)&info[10]);
|
|
||||||
|
|
||||||
unsigned char data [width*4];
|
|
||||||
tft_draw_rectangle(100-1,160-1,100-1+width,160-1+height,BLACK);
|
|
||||||
|
|
||||||
for(int i = 0; i < height; i++)
|
|
||||||
{
|
|
||||||
filesystem_file_read(file,data,width*4);
|
|
||||||
for(int j = 0; j < width*4; j += 4)
|
|
||||||
{
|
|
||||||
unsigned char a = data[j];
|
|
||||||
unsigned char r = data[j+1];
|
|
||||||
unsigned char g = data[j+2];
|
|
||||||
unsigned char b = data[j+3];
|
|
||||||
if(a!=0) {
|
|
||||||
tft_draw_pixel(100+j/4,160+height-1-i,RGB(r,g,b));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
filesystem_file_close(file);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
emulator/emulated/pixy_large.bmp
Normal file
BIN
emulator/emulated/pixy_large.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 205 KiB |
BIN
emulator/emulated/pixy_small.bmp
Normal file
BIN
emulator/emulated/pixy_small.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
emulator/emulated/stm_small.bmp
Normal file
BIN
emulator/emulated/stm_small.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Reference in New Issue
Block a user