Merge lp:~tino79/widelands/fix_screenshots into lp:widelands

Proposed by Tino
Status: Merged
Merged at revision: 7283
Proposed branch: lp:~tino79/widelands/fix_screenshots
Merge into: lp:widelands
Diff against target: 35 lines (+5/-6)
1 file modified
src/graphic/image_io.cc (+5/-6)
To merge this branch: bzr merge lp:~tino79/widelands/fix_screenshots
Reviewer Review Type Date Requested Status
SirVer Needs Fixing
GunChleoc Approve
Review via email: mp+243182@code.launchpad.net

Description of the change

When saving a screenshot don't use alpha channel

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

That fixes it :)

review: Approve
Revision history for this message
SirVer (sirver) wrote :

Unfortunately this fix introduces other bugs. The same function is used to save all surfaces to files in Widelands, for example also the custom graphics in scenarios that might contain RGBA data, so this fix is not correct.

My suggested fix: introduce a enum class Format { RGB, RGBA }; and take it as an extra parameter to the save_surface function and fix the call sites to use RGBA everywhere, but when saving screenshots.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/graphic/image_io.cc'
2--- src/graphic/image_io.cc 2014-11-24 07:10:03 +0000
3+++ src/graphic/image_io.cc 2014-11-28 18:44:33 +0000
4@@ -104,7 +104,7 @@
5 surface->width(),
6 surface->height(),
7 8,
8- PNG_COLOR_TYPE_RGB_ALPHA,
9+ PNG_COLOR_TYPE_RGB,
10 PNG_INTERLACE_NONE,
11 PNG_COMPRESSION_TYPE_DEFAULT,
12 PNG_FILTER_TYPE_DEFAULT);
13@@ -114,7 +114,7 @@
14 {
15 const uint16_t surf_w = surface->width();
16 const uint16_t surf_h = surface->height();
17- const uint32_t row_size = 4 * surf_w;
18+ const uint32_t row_size = 3 * surf_w;
19
20 std::unique_ptr<png_byte[]> row(new png_byte[row_size]);
21
22@@ -127,10 +127,9 @@
23 for (uint32_t x = 0; x < surf_w; ++x) {
24 RGBAColor color;
25 color.set(fmt, surface->get_pixel(x, y));
26- row[4 * x] = color.r;
27- row[4 * x + 1] = color.g;
28- row[4 * x + 2] = color.b;
29- row[4 * x + 3] = color.a;
30+ row[3 * x] = color.r;
31+ row[3 * x + 1] = color.g;
32+ row[3 * x + 2] = color.b;
33 }
34
35 png_write_row(png_ptr, row.get());

Subscribers

People subscribed via source and target branches

to status/vote changes: