OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/codec/png_codec.h" | 5 #include "ui/gfx/codec/png_codec.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "ui/gfx/size.h" | 10 #include "ui/gfx/size.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 | 57 |
58 void ConvertSkiatoRGB(const unsigned char* skia, int pixel_width, | 58 void ConvertSkiatoRGB(const unsigned char* skia, int pixel_width, |
59 unsigned char* rgb, bool* is_opaque) { | 59 unsigned char* rgb, bool* is_opaque) { |
60 for (int x = 0; x < pixel_width; x++) { | 60 for (int x = 0; x < pixel_width; x++) { |
61 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[x * 4]); | 61 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[x * 4]); |
62 unsigned char* pixel_out = &rgb[x * 3]; | 62 unsigned char* pixel_out = &rgb[x * 3]; |
63 | 63 |
64 int alpha = SkGetPackedA32(pixel_in); | 64 int alpha = SkGetPackedA32(pixel_in); |
65 if (alpha != 0 && alpha != 255) { | 65 if (alpha != 0 && alpha != 255) { |
66 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in); | 66 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in); |
67 pixel_out[0] = SkColorGetR(unmultiplied); | 67 pixel_out[0] = SkGetPackedR32(unmultiplied); |
68 pixel_out[1] = SkColorGetG(unmultiplied); | 68 pixel_out[1] = SkGetPackedG32(unmultiplied); |
69 pixel_out[2] = SkColorGetB(unmultiplied); | 69 pixel_out[2] = SkGetPackedB32(unmultiplied); |
tony
2012/07/26 17:38:21
Since the else block does the same as this, I woul
| |
70 } else { | 70 } else { |
71 pixel_out[0] = SkGetPackedR32(pixel_in); | 71 pixel_out[0] = SkGetPackedR32(pixel_in); |
72 pixel_out[1] = SkGetPackedG32(pixel_in); | 72 pixel_out[1] = SkGetPackedG32(pixel_in); |
73 pixel_out[2] = SkGetPackedB32(pixel_in); | 73 pixel_out[2] = SkGetPackedB32(pixel_in); |
74 } | 74 } |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void ConvertSkiatoRGBA(const unsigned char* skia, int pixel_width, | 78 void ConvertSkiatoRGBA(const unsigned char* skia, int pixel_width, |
79 unsigned char* rgba, bool* is_opaque) { | 79 unsigned char* rgba, bool* is_opaque) { |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 } | 783 } |
784 | 784 |
785 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) | 785 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) |
786 : key(k), text(t) { | 786 : key(k), text(t) { |
787 } | 787 } |
788 | 788 |
789 PNGCodec::Comment::~Comment() { | 789 PNGCodec::Comment::~Comment() { |
790 } | 790 } |
791 | 791 |
792 } // namespace gfx | 792 } // namespace gfx |
OLD | NEW |