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

Side by Side Diff: chrome/browser/importer/importer_util.cc

Issue 14575004: Extract BookmarksFileImporter from Firefox2Importer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test cleanup Created 7 years, 7 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/importer/importer_util.h"
6
7 #include "skia/ext/image_operations.h"
8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "ui/gfx/codec/png_codec.h"
10 #include "ui/gfx/favicon_size.h"
11 #include "webkit/glue/image_decoder.h"
12
13 namespace importer {
14
15 bool ReencodeFavicon(const unsigned char* src_data,
16 size_t src_len,
17 std::vector<unsigned char>* png_data) {
18 // Decode the favicon using WebKit's image decoder.
19 webkit_glue::ImageDecoder decoder(
20 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize));
21 SkBitmap decoded = decoder.Decode(src_data, src_len);
22 if (decoded.empty())
23 return false; // Unable to decode.
24
25 if (decoded.width() != gfx::kFaviconSize ||
26 decoded.height() != gfx::kFaviconSize) {
27 // The bitmap is not the correct size, re-sample.
28 int new_width = decoded.width();
29 int new_height = decoded.height();
30 gfx::CalculateFaviconTargetSize(&new_width, &new_height);
31 decoded = skia::ImageOperations::Resize(
32 decoded, skia::ImageOperations::RESIZE_LANCZOS3, new_width, new_height);
33 }
34
35 // Encode our bitmap as a PNG.
36 gfx::PNGCodec::EncodeBGRASkBitmap(decoded, false, png_data);
37 return true;
38 }
39
40 } // namespace importer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698