summaryrefslogtreecommitdiffstats
path: root/base/gfx
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 23:57:59 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 23:57:59 +0000
commit8618fa7fa6a2f11c6e89a8fb00864306874b33fc (patch)
tree0e9988ce26f2b41d37b5ddb907f7054aad13a2ab /base/gfx
parentca33e969726b0ff6f1749d4dec117da2b9c4200b (diff)
downloadchromium_src-8618fa7fa6a2f11c6e89a8fb00864306874b33fc.zip
chromium_src-8618fa7fa6a2f11c6e89a8fb00864306874b33fc.tar.gz
chromium_src-8618fa7fa6a2f11c6e89a8fb00864306874b33fc.tar.bz2
Revert pngencoder changes.
BUG=none TEST=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/gfx')
-rw-r--r--base/gfx/png_encoder.cc41
1 files changed, 5 insertions, 36 deletions
diff --git a/base/gfx/png_encoder.cc b/base/gfx/png_encoder.cc
index cdc8fbc..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,39 +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) {
- static const int bbp = 4;
-
- SkAutoLockPixels lock_input(input);
- DCHECK(input.bytesPerPixel() == bbp);
- DCHECK(input.getConfig() == SkBitmap::kARGB_8888_Config);
- DCHECK(input.width() > 1 && input.height() > 1);
-
- // SkBitmaps are premultiplied, we need to unpremultiply them.
- scoped_array<unsigned char> divided(
- new unsigned char[input.width() * input.height() * bbp]);
-
- int i = 0;
- for (int y = 0; y < input.height(); y++) {
- for (int x = 0; x < input.width(); x++) {
- uint32 pixel = input.getAddr32(0, y)[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] = alpha;
- }
- i += bbp;
- }
- }
-
- return Encode(divided.get(),
- PNGEncoder::FORMAT_RGBA, input.width(), input.height(),
- input.width() * bbp, discard_transparency, output);
+ 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);
}