@@ -233,47 +233,65 @@ PImage PImage::loadImage(const char * fileName) {
233
233
uint32_t bmpImageoffset; // Start of image data in file
234
234
uint32_t rowSize; // Not always = bmpWidth; may have padding
235
235
bool flip = true ; // BMP is stored bottom-to-top
236
+ uint32_t bmpFilesize;
237
+ uint32_t bmpHeadersize;
236
238
237
239
238
240
// Open requested file on SD card
239
241
if ((bmpFile = SD.open (fileName)) == false ) {
242
+ #if defined(LCD_SCREEN_DEBUG)
240
243
Serial.print (F (" loadImage: file not found: " ));
241
244
Serial.println (fileName);
245
+ #endif
242
246
return PImage (); // load error
243
247
}
244
248
245
249
246
250
247
251
// Parse BMP header
248
252
if (read16 (bmpFile) != 0x4D42 ) { // BMP signature
253
+ #if defined(LCD_SCREEN_DEBUG)
249
254
Serial.println (F (" loadImage: file doesn't look like a BMP" ));
255
+ #endif
250
256
return PImage ();
251
257
}
252
258
253
- Serial. print ( F ( " File size: " )); Serial. println ( read32 (bmpFile) );
259
+ bmpFilesize = read32 (bmpFile);
254
260
(void )read32 (bmpFile); // Read & ignore creator bytes
255
261
bmpImageoffset = read32 (bmpFile); // Start of image data
256
- Serial.print (F (" Image Offset: " )); Serial.println (bmpImageoffset, DEC);
257
262
// Read DIB header
258
- Serial. print ( F ( " Header size: " )); Serial. println ( read32 (bmpFile));
259
- bmpWidth = read32 (bmpFile);
263
+ bmpHeadersize = read32 (bmpFile);
264
+ bmpWidth = read32 (bmpFile);
260
265
bmpHeight = read32 (bmpFile);
266
+ #if defined(LCD_SCREEN_DEBUG)
267
+ Serial.print (F (" File size: " )); Serial.println (bmpFilesize);
268
+ Serial.print (F (" Image Offset: " )); Serial.println (bmpImageoffset, DEC);
269
+ Serial.print (F (" Header size: " )); Serial.println (bmpHeadersize);
270
+ #endif
261
271
if (read16 (bmpFile) != 1 ) { // # planes -- must be '1'
272
+ #if defined(LCD_SCREEN_DEBUG)
262
273
Serial.println (F (" loadImage: invalid n. of planes" ));
274
+ #endif
263
275
return PImage ();
264
276
}
265
277
266
278
bmpDepth = read16 (bmpFile); // bits per pixel
279
+ #if defined(LCD_SCREEN_DEBUG)
267
280
Serial.print (F (" Bit Depth: " )); Serial.println (bmpDepth);
281
+ #endif
268
282
if ((bmpDepth != 24 ) || (read32 (bmpFile) != 0 )) { // 0 = uncompressed {
283
+ #if defined(LCD_SCREEN_DEBUG)
269
284
Serial.println (F (" loadImage: invalid pixel format" ));
285
+ #endif
270
286
return PImage ();
271
287
}
272
288
289
+ #if defined(LCD_SCREEN_DEBUG)
273
290
Serial.print (F (" Image size: " ));
274
291
Serial.print (bmpWidth);
275
292
Serial.print (' x' );
276
293
Serial.println (bmpHeight);
294
+ #endif
277
295
278
296
// BMP rows are padded (if needed) to 4-byte boundary
279
297
rowSize = (bmpWidth * 3 + 3 ) & ~3 ;
0 commit comments