mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-09 15:12:35 -04:00
Removed drawRAW.
- BMP files can be loaded directly now, so it can be removed.
This commit is contained in:
parent
80f074b82f
commit
5cbbf62c5f
4 changed files with 1 additions and 163 deletions
|
@ -421,101 +421,6 @@ void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap, const bool tran
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Read a RAW image from SD card. (Mainly for splash screen)
|
||||
RAW image structure:
|
||||
First 3 bytes: file header "RAW"
|
||||
Byte 4: file type, 0: RGB565, 1: RGB, 2: RGBA (alpha ignored)
|
||||
Byte 5-6: height
|
||||
Byte 7-8: width
|
||||
*/
|
||||
bool ILI9341::drawRAW(const ui::Point p, const std::string file) {
|
||||
File rawimage;
|
||||
size_t file_pos = 0;
|
||||
uint16_t pointer = 0;
|
||||
uint16_t px = 0, py, width, height;
|
||||
uint8_t type = 0;
|
||||
char buffer[257];
|
||||
ui::Color line_buffer[240];
|
||||
|
||||
auto result = rawimage.open(file);
|
||||
if(result.is_valid())
|
||||
return false;
|
||||
|
||||
rawimage.seek(file_pos);
|
||||
memset(buffer, 0, 3);
|
||||
auto read_size = rawimage.read(buffer, 3);
|
||||
buffer[3] = '\0';
|
||||
if(strcmp(buffer, "RAW")) {
|
||||
return false; // Not a generated RAW file
|
||||
}
|
||||
|
||||
file_pos += 3;
|
||||
|
||||
rawimage.seek(file_pos);
|
||||
memset(buffer, 0, 5);
|
||||
read_size = rawimage.read(buffer, 5);
|
||||
if (read_size.is_error())
|
||||
return false;
|
||||
|
||||
py = 0;
|
||||
|
||||
type = buffer[0]; // 0: RGB565, 1: RGB, 2: RGBA(Alpha ignored). Default to RGBA.
|
||||
|
||||
height = (uint16_t)buffer[1] | ((uint16_t)buffer[2] << 8);
|
||||
width = (uint16_t)buffer[3] | ((uint16_t)buffer[4] << 8);
|
||||
|
||||
py += 16;
|
||||
|
||||
file_pos += 5;
|
||||
|
||||
while(1) {
|
||||
while(px < width) {
|
||||
rawimage.seek(file_pos);
|
||||
|
||||
memset(buffer, 0, 257);
|
||||
read_size = rawimage.read(buffer, 256);
|
||||
if (read_size.is_error())
|
||||
return false; // Read error
|
||||
|
||||
pointer = 0;
|
||||
while(pointer < 256) {
|
||||
switch(type) {
|
||||
case 0:
|
||||
line_buffer[px] = ui::Color((uint16_t)buffer[pointer] | ((uint16_t)buffer[pointer + 1] << 8));
|
||||
pointer += 2;
|
||||
file_pos += 2;
|
||||
break;
|
||||
case 1:
|
||||
line_buffer[px] = ui::Color(buffer[pointer], buffer[pointer + 1], buffer[pointer + 2]);
|
||||
pointer += 3;
|
||||
file_pos += 3;
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
line_buffer[px] = ui::Color(buffer[pointer], buffer[pointer + 1], buffer[pointer + 2]);
|
||||
pointer += 4;
|
||||
file_pos += 4;
|
||||
break;
|
||||
}
|
||||
px++;
|
||||
if(px >= width) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(read_size.value() != 256)
|
||||
break;
|
||||
}
|
||||
render_line({ p.x(), p.y() + py }, px, line_buffer);
|
||||
px = 0;
|
||||
py++;
|
||||
|
||||
if(read_size.value() < 256 || py > height + 16)
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Draw BMP from SD card.
|
||||
Currently supported formats:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue