aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skiaserve
diff options
context:
space:
mode:
authorGravatar ethannicholas <ethannicholas@google.com>2016-02-17 11:49:43 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-17 11:49:43 -0800
commitcecbbe2fa91d116d5c724ed9a1be9b6d82593e13 (patch)
tree88b6d69949e07d7a972344b6d521b47e5ebf6000 /tools/skiaserve
parentd9ec32090e95cebc7c1bb7c4fe29bef54629ef2c (diff)
converted skiaserve PNGs from RGBA to RGB
Diffstat (limited to 'tools/skiaserve')
-rw-r--r--tools/skiaserve/skiaserve.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/skiaserve/skiaserve.cpp b/tools/skiaserve/skiaserve.cpp
index 717e6855c4..cb58ffe9f8 100644
--- a/tools/skiaserve/skiaserve.cpp
+++ b/tools/skiaserve/skiaserve.cpp
@@ -106,12 +106,20 @@ static void write_png(const png_bytep rgba, png_uint_32 width, png_uint_32 heigh
if (setjmp(png_jmpbuf(png))) {
SkFAIL("png encode error");
}
- png_set_IHDR(png, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE,
+ png_set_IHDR(png, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_set_compression_level(png, 1);
png_bytepp rows = (png_bytepp) sk_malloc_throw(height * sizeof(png_byte*));
+ png_bytep pixels = (png_bytep) sk_malloc_throw(width * height * 3);
for (png_size_t y = 0; y < height; ++y) {
- rows[y] = (png_bytep) rgba + y * width * 4;
+ const png_bytep src = rgba + y * width * 4;
+ rows[y] = pixels + y * width * 3;
+ // convert from RGBA to RGB
+ for (png_size_t x = 0; x < width; ++x) {
+ rows[y][x * 3] = src[x * 4];
+ rows[y][x * 3 + 1] = src[x * 4 + 1];
+ rows[y][x * 3 + 2] = src[x * 4 + 2];
+ }
}
png_set_filter(png, 0, PNG_NO_FILTERS);
png_set_rows(png, info_ptr, &rows[0]);