Skip to content

Commit

Permalink
Fix incorrect color scaling factor
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaelangel007 committed May 9, 2016
1 parent e639fb4 commit 79c6545
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/save-bmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool saveBmp(const Bitmap<float> &bitmap, const char *filename) {
const uint8_t padding[4] = { };
for (int y = 0; y < bitmap.height(); ++y) {
for (int x = 0; x < bitmap.width(); ++x) {
uint8_t px = (uint8_t) clamp(int(bitmap(x, y)*0x100), 0xff);
uint8_t px = (uint8_t) clamp(int(bitmap(x, y)*0xFF), 0xff);
fwrite(&px, sizeof(uint8_t), 1, file);
fwrite(&px, sizeof(uint8_t), 1, file);
fwrite(&px, sizeof(uint8_t), 1, file);
Expand All @@ -94,9 +94,9 @@ bool saveBmp(const Bitmap<FloatRGB> &bitmap, const char *filename) {
for (int y = 0; y < bitmap.height(); ++y) {
for (int x = 0; x < bitmap.width(); ++x) {
uint8_t bgr[3] = {
(uint8_t) clamp(int(bitmap(x, y).b*0x100), 0xff),
(uint8_t) clamp(int(bitmap(x, y).g*0x100), 0xff),
(uint8_t) clamp(int(bitmap(x, y).r*0x100), 0xff)
(uint8_t) clamp(int(bitmap(x, y).b*0xFF), 0xff),
(uint8_t) clamp(int(bitmap(x, y).g*0xFF), 0xff),
(uint8_t) clamp(int(bitmap(x, y).r*0xFF), 0xff)
};
fwrite(bgr, sizeof(uint8_t), 3, file);
}
Expand Down

1 comment on commit 79c6545

@prepare
Copy link

@prepare prepare commented on 79c6545 Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chlumsky,
Is this your intention ?
:)

Please sign in to comment.