Skip to content

Commit 14377d1

Browse files
committed
C++ Bitmap Image Reader Writer Library http://partow.net/programming/bitmap/index.html
1 parent 94af1e2 commit 14377d1

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

bitmap_image.hpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ class bitmap_image
434434

435435
if (!stream)
436436
{
437-
std::cerr << "bitmap_image::save_image(): Error - Could not open file " << file_name << " for writing!" << std::endl;
437+
std::cerr << "bitmap_image::save_image(): Error - Could not open file "
438+
<< file_name << " for writing!" << std::endl;
438439
return;
439440
}
440441

@@ -1511,7 +1512,8 @@ class bitmap_image
15111512

15121513
if (!stream)
15131514
{
1514-
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - file " << file_name_ << " not found!" << std::endl;
1515+
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
1516+
<< "file " << file_name_ << " not found!" << std::endl;
15151517
return;
15161518
}
15171519

@@ -1529,36 +1531,41 @@ class bitmap_image
15291531

15301532
if (bfh.type != 19778)
15311533
{
1534+
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
1535+
<< "Invalid type value " << bfh.type << " expected 19778." << std::endl;
1536+
15321537
bfh.clear();
15331538
bih.clear();
15341539

15351540
stream.close();
15361541

1537-
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid type value " << bfh.type << " expected 19778." << std::endl;
15381542
return;
15391543
}
15401544

15411545
if (bih.bit_count != 24)
15421546
{
1547+
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
1548+
<< "Invalid bit depth " << bih.bit_count << " expected 24." << std::endl;
1549+
15431550
bfh.clear();
15441551
bih.clear();
15451552

15461553
stream.close();
15471554

1548-
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid bit depth " << bih.bit_count << " expected 24." << std::endl;
1549-
15501555
return;
15511556
}
15521557

15531558
if (bih.size != bih.struct_size())
15541559
{
1560+
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
1561+
<< "Invalid BIH size " << bih.size
1562+
<< " expected " << bih.struct_size() << std::endl;
1563+
15551564
bfh.clear();
15561565
bih.clear();
15571566

15581567
stream.close();
15591568

1560-
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid BIH size " << bih.size << " expected " << bih.struct_size() << std::endl;
1561-
15621569
return;
15631570
}
15641571

@@ -1568,7 +1575,7 @@ class bitmap_image
15681575
bytes_per_pixel_ = bih.bit_count >> 3;
15691576

15701577
unsigned int padding = (4 - ((3 * width_) % 4)) % 4;
1571-
char padding_data[4] = {0,0,0,0};
1578+
char padding_data[4] = { 0, 0, 0, 0 };
15721579

15731580
std::size_t bitmap_file_size = file_size(file_name_);
15741581

@@ -1584,9 +1591,10 @@ class bitmap_image
15841591

15851592
stream.close();
15861593

1587-
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Mismatch between logical and physical sizes of bitmap. " <<
1588-
"Logical: " << bitmap_logical_size << " " <<
1589-
"Physical: " << bitmap_file_size << std::endl;
1594+
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - "
1595+
<< "Mismatch between logical and physical sizes of bitmap. "
1596+
<< "Logical: " << bitmap_logical_size << " "
1597+
<< "Physical: " << bitmap_file_size << std::endl;
15901598

15911599
return;
15921600
}

0 commit comments

Comments
 (0)