Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: chrome/browser/gtk/nine_box.cc

Issue 155547: Don't try to set transparency on pixbufs that don't have any transparency.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/gtk/nine_box.h" 5 #include "chrome/browser/gtk/nine_box.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "app/theme_provider.h" 8 #include "app/theme_provider.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/gfx/gtk_util.h" 10 #include "base/gfx/gtk_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const int height = gdk_pixbuf_get_height(images_[1]); 131 const int height = gdk_pixbuf_get_height(images_[1]);
132 TileImage(cr, images_[1], x, y, width, height); 132 TileImage(cr, images_[1], x, y, width, height);
133 } 133 }
134 134
135 void NineBox::ChangeWhiteToTransparent() { 135 void NineBox::ChangeWhiteToTransparent() {
136 for (int image_idx = 0; image_idx < 9; ++image_idx) { 136 for (int image_idx = 0; image_idx < 9; ++image_idx) {
137 GdkPixbuf* pixbuf = images_[image_idx]; 137 GdkPixbuf* pixbuf = images_[image_idx];
138 if (!pixbuf) 138 if (!pixbuf)
139 continue; 139 continue;
140 140
141 if (!gdk_pixbuf_get_has_alpha(pixbuf))
142 continue;
143
141 guchar* pixels = gdk_pixbuf_get_pixels(pixbuf); 144 guchar* pixels = gdk_pixbuf_get_pixels(pixbuf);
142 int rowstride = gdk_pixbuf_get_rowstride(pixbuf); 145 int rowstride = gdk_pixbuf_get_rowstride(pixbuf);
146 int width = gdk_pixbuf_get_width(pixbuf);
147 int height = gdk_pixbuf_get_height(pixbuf);
143 148
144 for (int i = 0; i < gdk_pixbuf_get_height(pixbuf); ++i) { 149 if (width * 4 > rowstride) {
145 for (int j = 0; j < gdk_pixbuf_get_width(pixbuf); ++j) { 150 NOTREACHED();
151 continue;
152 }
153
154 for (int i = 0; i < height; ++i) {
155 for (int j = 0; j < width; ++j) {
146 guchar* pixel = &pixels[i * rowstride + j * 4]; 156 guchar* pixel = &pixels[i * rowstride + j * 4];
147 if (pixel[0] == 0xff && pixel[1] == 0xff && pixel[2] == 0xff) { 157 if (pixel[0] == 0xff && pixel[1] == 0xff && pixel[2] == 0xff) {
148 pixel[3] = 0; 158 pixel[3] = 0;
149 } 159 }
150 } 160 }
151 } 161 }
152 } 162 }
153 } 163 }
154 164
155 void NineBox::ContourWidget(GtkWidget* widget) const { 165 void NineBox::ContourWidget(GtkWidget* widget) const {
(...skipping 30 matching lines...) Expand all
186 NOTREACHED(); 196 NOTREACHED();
187 return; 197 return;
188 } 198 }
189 199
190 // Reload images. 200 // Reload images.
191 for (size_t i = 0; i < arraysize(image_ids_); ++i) { 201 for (size_t i = 0; i < arraysize(image_ids_); ++i) {
192 images_[i] = image_ids_[i] ? 202 images_[i] = image_ids_[i] ?
193 theme_provider_->GetPixbufNamed(image_ids_[i]) : NULL; 203 theme_provider_->GetPixbufNamed(image_ids_[i]) : NULL;
194 } 204 }
195 } 205 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698