Cosmetics

This commit is contained in:
Bertrand Songis
2018-08-05 15:58:16 +02:00
parent 4f741dfad2
commit 92de1313e7
+19 -19
View File
@@ -541,23 +541,23 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
FRESULT result = f_open(&imgFile, filename, FA_OPEN_EXISTING | FA_READ);
if (result != FR_OK) {
return NULL;
return nullptr;
}
if (f_size(&imgFile) < 14) {
f_close(&imgFile);
return NULL;
return nullptr;
}
result = f_read(&imgFile, buf, 14, &read);
if (result != FR_OK || read != 14) {
f_close(&imgFile);
return NULL;
return nullptr;
}
if (buf[0] != 'B' || buf[1] != 'M') {
f_close(&imgFile);
return NULL;
return nullptr;
}
uint32_t fsize = *((uint32_t *)&buf[2]);
@@ -567,7 +567,7 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
result = f_read(&imgFile, buf, len, &read);
if (result != FR_OK || read != len) {
f_close(&imgFile);
return NULL;
return nullptr;
}
uint32_t ihsize = *((uint32_t *)&buf[0]); /* more header size */
@@ -575,7 +575,7 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
/* invalid header size */
if (ihsize + 14 > hsize) {
f_close(&imgFile);
return NULL;
return nullptr;
}
/* sometimes file size is set to some headers size, set a real size in that case */
@@ -585,7 +585,7 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
/* declared file size less than header size */
if (fsize <= hsize) {
f_close(&imgFile);
return NULL;
return nullptr;
}
uint32_t w, h;
@@ -607,12 +607,12 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
break;
default:
f_close(&imgFile);
return NULL;
return nullptr;
}
if (*((uint16_t *)&buf[0]) != 1) { /* planes */
f_close(&imgFile);
return NULL;
return nullptr;
}
uint16_t depth = *((uint16_t *)&buf[2]);
@@ -622,7 +622,7 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
if (depth == 4) {
if (f_lseek(&imgFile, hsize-64) != FR_OK || f_read(&imgFile, buf, 64, &read) != FR_OK || read != 64) {
f_close(&imgFile);
return NULL;
return nullptr;
}
for (uint8_t i=0; i<16; i++) {
palette[i] = buf[4*i];
@@ -631,14 +631,14 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
else {
if (f_lseek(&imgFile, hsize) != FR_OK) {
f_close(&imgFile);
return NULL;
return nullptr;
}
}
BitmapBuffer * bmp = new BitmapBuffer(BMP_RGB565, w, h);
if (bmp == NULL || bmp->getData() == NULL) {
if (bmp == nullptr || bmp->getData() == nullptr) {
f_close(&imgFile);
return NULL;
return nullptr;
}
uint32_t rowSize;
@@ -654,7 +654,7 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
if (result != FR_OK || read != 4) {
f_close(&imgFile);
delete bmp;
return NULL;
return nullptr;
}
if (hasAlpha) {
*dst = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
@@ -688,7 +688,7 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
if (result != FR_OK || read != rowSize) {
f_close(&imgFile);
delete bmp;
return NULL;
return nullptr;
}
display_t * dst = bmp->getPixelPtr(0, i);
for (uint32_t j=0; j<w; j++) {
@@ -703,7 +703,7 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
default:
f_close(&imgFile);
delete bmp;
return NULL;
return nullptr;
}
f_close(&imgFile);
@@ -787,7 +787,7 @@ BitmapBuffer * BitmapBuffer::load_stb(const char * filename)
{
FRESULT result = f_open(&imgFile, filename, FA_OPEN_EXISTING | FA_READ);
if (result != FR_OK) {
return NULL;
return nullptr;
}
int w, h, n;
@@ -795,7 +795,7 @@ BitmapBuffer * BitmapBuffer::load_stb(const char * filename)
f_close(&imgFile);
if (!img) {
return NULL;
return nullptr;
}
// convert to RGB565 or ARGB4444 format
@@ -803,7 +803,7 @@ BitmapBuffer * BitmapBuffer::load_stb(const char * filename)
if (bmp == NULL) {
TRACE("load_stb() malloc failed");
stbi_image_free(img);
return NULL;
return nullptr;
}
#if 0