This source file includes following definitions.
- ReencodeFavicon
#include "chrome/utility/importer/favicon_reencode.h"
#include "content/public/child/image_decoder_utils.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/favicon_size.h"
namespace importer {
bool ReencodeFavicon(const unsigned char* src_data,
size_t src_len,
std::vector<unsigned char>* png_data) {
SkBitmap decoded = content::DecodeImage(
src_data,
gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize),
src_len);
if (decoded.empty())
return false;
if (decoded.width() != gfx::kFaviconSize ||
decoded.height() != gfx::kFaviconSize) {
int new_width = decoded.width();
int new_height = decoded.height();
gfx::CalculateFaviconTargetSize(&new_width, &new_height);
decoded = skia::ImageOperations::Resize(
decoded, skia::ImageOperations::RESIZE_LANCZOS3, new_width, new_height);
}
gfx::PNGCodec::EncodeBGRASkBitmap(decoded, false, png_data);
return true;
}
}