Cosmetics

This commit is contained in:
Bertrand Songis
2020-01-09 22:50:56 +01:00
parent 40e994dca3
commit fc7fa5fe94
107 changed files with 124 additions and 113 deletions
+16 -16
View File
@@ -29,28 +29,28 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
uint8_t * buf = &bmpBuf[0];
if (width > LCD_W) {
return NULL;
return nullptr;
}
FRESULT result = f_open(&bmpFile, filename, FA_OPEN_EXISTING | FA_READ);
if (result != FR_OK) {
return NULL;
return nullptr;
}
if (f_size(&bmpFile) < 14) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
result = f_read(&bmpFile, buf, 14, &read);
if (result != FR_OK || read != 14) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
if (buf[0] != 'B' || buf[1] != 'M') {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint32_t fsize = *((uint32_t *)&buf[2]);
@@ -60,7 +60,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
result = f_read(&bmpFile, buf, len, &read);
if (result != FR_OK || read != len) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint32_t ihsize = *((uint32_t *)&buf[0]); /* more header size */
@@ -68,7 +68,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
/* invalid header size */
if (ihsize + 14 > hsize) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
/* sometimes file size is set to some headers size, set a real size in that case */
@@ -78,7 +78,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
/* declared file size less than header size */
if (fsize <= hsize) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint32_t w, h;
@@ -100,17 +100,17 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
break;
default:
f_close(&bmpFile);
return NULL;
return nullptr;
}
if (*((uint16_t *)&buf[0]) != 1) { /* planes */
f_close(&bmpFile);
return NULL;
return nullptr;
}
if (w > width || h > height) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint16_t depth = *((uint16_t *)&buf[2]);
@@ -120,7 +120,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
if (depth == 4) {
if (f_lseek(&bmpFile, hsize-64) != FR_OK || f_read(&bmpFile, buf, 64, &read) != FR_OK || read != 64) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
for (uint8_t i=0; i<16; i++) {
palette[i] = buf[4*i] >> 4;
@@ -129,7 +129,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
else {
if (f_lseek(&bmpFile, hsize) != FR_OK) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
}
@@ -149,7 +149,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
result = f_read(&bmpFile, buf, rowSize*2, &read);
if (result != FR_OK || read != rowSize*2) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
for (uint32_t j=0; j<w; j++) {
@@ -168,7 +168,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
result = f_read(&bmpFile, buf, rowSize, &read);
if (result != FR_OK || read != rowSize) {
f_close(&bmpFile);
return NULL;
return nullptr;
}
uint8_t * dst = dest + (i/2)*w;
for (uint32_t j=0; j<w; j++) {
@@ -181,7 +181,7 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
default:
f_close(&bmpFile);
return NULL;
return nullptr;
}
f_close(&bmpFile);