summaryrefslogtreecommitdiffstats
path: root/gfx/skbitmap_operations.cc
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-15 15:30:55 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-15 15:30:55 +0000
commit3eaf0ecd7a4882482d6234f7a115d1b019c13339 (patch)
tree327b0b0078ed2bdfa101986fb3ae51edc1c87275 /gfx/skbitmap_operations.cc
parent3d428737173006823333a2635df6c4c15ad739a7 (diff)
downloadchromium_src-3eaf0ecd7a4882482d6234f7a115d1b019c13339.zip
chromium_src-3eaf0ecd7a4882482d6234f7a115d1b019c13339.tar.gz
chromium_src-3eaf0ecd7a4882482d6234f7a115d1b019c13339.tar.bz2
Windows: Fix opacity of drag images.
BUG=XXX TEST=Go to google.com, drag logo around. Preview image should now look nice. Review URL: http://codereview.chromium.org/2963009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/skbitmap_operations.cc')
-rw-r--r--gfx/skbitmap_operations.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/gfx/skbitmap_operations.cc b/gfx/skbitmap_operations.cc
index 27508ba..b8cec11 100644
--- a/gfx/skbitmap_operations.cc
+++ b/gfx/skbitmap_operations.cc
@@ -668,3 +668,30 @@ SkBitmap SkBitmapOperations::DownsampleByTwo(const SkBitmap& bitmap) {
return result;
}
+// static
+SkBitmap SkBitmapOperations::UnPreMultiply(const SkBitmap& bitmap) {
+ if (bitmap.isNull())
+ return bitmap;
+ if (bitmap.isOpaque())
+ return bitmap;
+
+ SkBitmap opaque_bitmap;
+ opaque_bitmap.setConfig(bitmap.config(), bitmap.width(), bitmap.height());
+ opaque_bitmap.allocPixels();
+
+ {
+ SkAutoLockPixels bitmap_lock(bitmap);
+ SkAutoLockPixels opaque_bitmap_lock(opaque_bitmap);
+ for (int y = 0; y < opaque_bitmap.height(); y++) {
+ for (int x = 0; x < opaque_bitmap.width(); x++) {
+ uint32 src_pixel = *bitmap.getAddr32(x, y);
+ uint32* dst_pixel = opaque_bitmap.getAddr32(x, y);
+ SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(src_pixel);
+ *dst_pixel = unmultiplied;
+ }
+ }
+ }
+
+ opaque_bitmap.setIsOpaque(true);
+ return opaque_bitmap;
+}