diff options
author | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 23:05:22 +0000 |
---|---|---|
committer | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 23:05:22 +0000 |
commit | 8b6c1e3833d5030da152ef816ba0f6673082c25a (patch) | |
tree | 3fc05aeee19b02fe8c26755cc6295eecf2825c4b /base/gfx | |
parent | 47b4e5fa63a79f8ca74c5dace16d8b4a9186e88e (diff) | |
download | chromium_src-8b6c1e3833d5030da152ef816ba0f6673082c25a.zip chromium_src-8b6c1e3833d5030da152ef816ba0f6673082c25a.tar.gz chromium_src-8b6c1e3833d5030da152ef816ba0f6673082c25a.tar.bz2 |
Revert png encoder changes.
BUG=none
TEST=none
TBR=nick
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/gfx')
-rw-r--r-- | base/gfx/png_encoder.cc | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/base/gfx/png_encoder.cc b/base/gfx/png_encoder.cc index 9d93fe6..5021721 100644 --- a/base/gfx/png_encoder.cc +++ b/base/gfx/png_encoder.cc @@ -5,7 +5,6 @@ #include "base/basictypes.h" #include "base/gfx/png_encoder.h" #include "base/logging.h" -#include "base/scoped_ptr.h" #include "third_party/skia/include/core/SkBitmap.h" extern "C" { @@ -198,44 +197,9 @@ bool PNGEncoder::Encode(const unsigned char* input, ColorFormat format, bool PNGEncoder::EncodeBGRASkBitmap(const SkBitmap& input, bool discard_transparency, std::vector<unsigned char>* output) { - // This only works with images with four bytes per pixel. - static const int bbp = 4; - - DCHECK(!input.empty()); - DCHECK(input.bytesPerPixel() == bbp); - DCHECK(input.config() == SkBitmap::kARGB_8888_Config); - - // SkBitmaps are premultiplied, we need to unpremultiply them. - scoped_array<unsigned char> divided( - new unsigned char[input.width() * input.height() * bbp]); - - SkAutoLockPixels lock_input(input); - - int i = 0; - for (int y = 0; y < input.height(); y++) { - uint32* src_row = input.getAddr32(0, y); - - for (int x = 0; x < input.width(); x++) { - uint32 pixel = src_row[x]; - int alpha = SkColorGetA(pixel); - - if (alpha != 0 && alpha != 255) { - divided[i + 0] = (SkColorGetR(pixel) << 8) / alpha; - divided[i + 1] = (SkColorGetG(pixel) << 8) / alpha; - divided[i + 2] = (SkColorGetB(pixel) << 8) / alpha; - divided[i + 3] = alpha; - } else { - divided[i + 0] = SkColorGetR(pixel); - divided[i + 1] = SkColorGetG(pixel); - divided[i + 2] = SkColorGetB(pixel); - divided[i + 3] = SkColorGetA(pixel); - } - - i += bbp; - } - } - - return Encode(divided.get(), - PNGEncoder::FORMAT_RGBA, input.width(), input.height(), + SkAutoLockPixels input_lock(input); + DCHECK(input.empty() || input.bytesPerPixel() == 4); + return Encode(static_cast<unsigned char*>(input.getPixels()), + PNGEncoder::FORMAT_BGRA, input.width(), input.height(), input.rowBytes(), discard_transparency, output); } |