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

Side by Side Diff: chrome/browser/ui/webui/web_ui_util.cc

Issue 10453101: Convert most of the rest of chrome to ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | « chrome/browser/ui/webui/web_ui_util.h ('k') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/web_ui_util.h" 5 #include "chrome/browser/ui/webui/web_ui_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted_memory.h" 11 #include "base/memory/ref_counted_memory.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/disposition_utils.h" 13 #include "chrome/browser/disposition_utils.h"
14 #include "ui/base/layout.h" 14 #include "ui/base/layout.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/codec/png_codec.h" 16 #include "ui/gfx/codec/png_codec.h"
17 #include "ui/gfx/image/image_skia.h"
17 18
18 namespace web_ui_util { 19 namespace web_ui_util {
19 20
20 std::string GetImageDataUrl(const SkBitmap& bitmap) { 21 std::string GetImageDataUrl(const gfx::ImageSkia& image) {
21 std::vector<unsigned char> output; 22 std::vector<unsigned char> output;
22 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &output); 23 gfx::PNGCodec::EncodeBGRASkBitmap(*image.bitmap(), false, &output);
23 std::string str_url; 24 std::string str_url;
24 str_url.insert(str_url.end(), output.begin(), output.end()); 25 str_url.insert(str_url.end(), output.begin(), output.end());
25 26
26 base::Base64Encode(str_url, &str_url); 27 base::Base64Encode(str_url, &str_url);
27 str_url.insert(0, "data:image/png;base64,"); 28 str_url.insert(0, "data:image/png;base64,");
28 return str_url; 29 return str_url;
29 } 30 }
30 31
31 std::string GetImageDataUrlFromResource(int res) { 32 std::string GetImageDataUrlFromResource(int res) {
32 // Load resource icon and covert to base64 encoded data url 33 // Load resource icon and covert to base64 encoded data url
(...skipping 24 matching lines...) Expand all
57 CHECK(args->GetBoolean(start_index++, &alt_key)); 58 CHECK(args->GetBoolean(start_index++, &alt_key));
58 CHECK(args->GetBoolean(start_index++, &ctrl_key)); 59 CHECK(args->GetBoolean(start_index++, &ctrl_key));
59 CHECK(args->GetBoolean(start_index++, &meta_key)); 60 CHECK(args->GetBoolean(start_index++, &meta_key));
60 CHECK(args->GetBoolean(start_index++, &shift_key)); 61 CHECK(args->GetBoolean(start_index++, &shift_key));
61 return disposition_utils::DispositionFromClick(button == 1.0, alt_key, 62 return disposition_utils::DispositionFromClick(button == 1.0, alt_key,
62 ctrl_key, meta_key, shift_key); 63 ctrl_key, meta_key, shift_key);
63 64
64 } 65 }
65 66
66 } // namespace web_ui_util 67 } // namespace web_ui_util
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/web_ui_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698