| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/common/security_filter_peer.h" | 5 #include "chrome/common/security_filter_peer.h" |
| 6 | 6 |
| 7 #include "base/gfx/png_encoder.h" | 7 #include "base/gfx/png_encoder.h" |
| 8 #include "base/gfx/size.h" | 8 #include "base/gfx/size.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 x += stamp_bitmap->width() * 2) { | 291 x += stamp_bitmap->width() * 2) { |
| 292 canvas.drawBitmap(*stamp_bitmap, | 292 canvas.drawBitmap(*stamp_bitmap, |
| 293 SkIntToScalar(x), | 293 SkIntToScalar(x), |
| 294 SkIntToScalar(row * stamp_bitmap->height()), | 294 SkIntToScalar(row * stamp_bitmap->height()), |
| 295 &paint); | 295 &paint); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 // Now encode it to a PNG. | 299 // Now encode it to a PNG. |
| 300 std::vector<unsigned char> output; | 300 std::vector<unsigned char> output; |
| 301 unsigned char* input = | 301 if (!PNGEncoder::EncodeBGRASkBitmap(canvas.getDevice()->accessBitmap(false), |
| 302 static_cast<unsigned char*>(canvas.getDevice()->accessBitmap(false). | 302 false, &output)) { |
| 303 getPixels()); | |
| 304 if (!PNGEncoder::Encode(input, | |
| 305 PNGEncoder::FORMAT_BGRA, | |
| 306 image.width(), image.height(), | |
| 307 image.width() * 4, false, &output)) { | |
| 308 return false; | 303 return false; |
| 309 } | 304 } |
| 310 | 305 |
| 311 // Copy the vector content to data_ which is a string. | 306 // Copy the vector content to data_ which is a string. |
| 312 data_.clear(); | 307 data_.clear(); |
| 313 data_.resize(output.size()); | 308 data_.resize(output.size()); |
| 314 std::copy(output.begin(), output.end(), data_.begin()); | 309 std::copy(output.begin(), output.end(), data_.begin()); |
| 315 | 310 |
| 316 return true; | 311 return true; |
| 317 } | 312 } |
| 318 | 313 |
| OLD | NEW |