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

Side by Side Diff: components/suggestions/image_encoder.cc

Issue 641513003: [Suggestions] Introduce a different image encoder/decoder for iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest Created 6 years, 2 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
OLDNEW
(Empty)
1 // Copyright 2014 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 "components/suggestions/image_encoder.h"
6
7 #include "ui/gfx/codec/jpeg_codec.h"
8 #include "ui/gfx/image/image_skia.h"
9
10 namespace suggestions {
11
12 SkBitmap* DecodeJPEGToSkBitmap(const std::vector<unsigned char>& encoded_data) {
13 return gfx::JPEGCodec::Decode(&encoded_data[0], encoded_data.size());
14 }
15
16 bool EncodeSkBitmapToJPEG(const SkBitmap& bitmap,
17 std::vector<unsigned char>* dest) {
18 SkAutoLockPixels bitmap_lock(bitmap);
19 if (!bitmap.readyToDraw() || bitmap.isNull()) {
20 return false;
21 }
22 return gfx::JPEGCodec::Encode(
23 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
24 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(),
25 bitmap.rowBytes(), 100, dest);
26 }
27
28 } // namespace suggestions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698