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

Side by Side Diff: ui/gfx/image/image_util.cc

Issue 2592983002: [devtools] Support different encodings for Page.CaptureScreenshot. (Closed)
Patch Set: Disabled test on MacOS >=10.11, added ref to bug. Created 3 years, 10 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
« no previous file with comments | « ui/gfx/image/image_util.h ('k') | ui/gfx/image/image_util_mac.mm » ('j') | 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 "ui/gfx/image/image_util.h" 5 #include "ui/gfx/image/image_util.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 26 matching lines...) Expand all
37 #if !defined(OS_IOS) 37 #if !defined(OS_IOS)
38 Image ImageFrom1xJPEGEncodedData(const unsigned char* input, 38 Image ImageFrom1xJPEGEncodedData(const unsigned char* input,
39 size_t input_size) { 39 size_t input_size) {
40 std::unique_ptr<SkBitmap> bitmap(gfx::JPEGCodec::Decode(input, input_size)); 40 std::unique_ptr<SkBitmap> bitmap(gfx::JPEGCodec::Decode(input, input_size));
41 if (bitmap.get()) 41 if (bitmap.get())
42 return Image::CreateFrom1xBitmap(*bitmap); 42 return Image::CreateFrom1xBitmap(*bitmap);
43 43
44 return Image(); 44 return Image();
45 } 45 }
46 46
47 bool JPEG1xEncodedDataFromImage(const Image& image, int quality, 47 // The MacOS implementation of this function is in image_utils_mac.mm.
48 #if !defined(OS_MACOSX)
49 bool JPEG1xEncodedDataFromImage(const Image& image,
50 int quality,
48 std::vector<unsigned char>* dst) { 51 std::vector<unsigned char>* dst) {
52 return JPEG1xEncodedDataFromSkiaRepresentation(image, quality, dst);
53 }
54 #endif // !defined(OS_MACOSX)
55
56 bool JPEG1xEncodedDataFromSkiaRepresentation(const Image& image,
57 int quality,
58 std::vector<unsigned char>* dst) {
49 const gfx::ImageSkiaRep& image_skia_rep = 59 const gfx::ImageSkiaRep& image_skia_rep =
50 image.AsImageSkia().GetRepresentation(1.0f); 60 image.AsImageSkia().GetRepresentation(1.0f);
51 if (image_skia_rep.scale() != 1.0f) 61 if (image_skia_rep.scale() != 1.0f)
52 return false; 62 return false;
53 63
54 const SkBitmap& bitmap = image_skia_rep.sk_bitmap(); 64 const SkBitmap& bitmap = image_skia_rep.sk_bitmap();
55 SkAutoLockPixels bitmap_lock(bitmap); 65 SkAutoLockPixels bitmap_lock(bitmap);
56 66
57 if (!bitmap.readyToDraw()) 67 if (!bitmap.readyToDraw())
58 return false; 68 return false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Since we already know column *left is non-transparent, we can avoid 105 // Since we already know column *left is non-transparent, we can avoid
96 // rechecking that column; hence the '>' here. 106 // rechecking that column; hence the '>' here.
97 for (x = bitmap.width() - 1; x > *left; --x) { 107 for (x = bitmap.width() - 1; x > *left; --x) {
98 if (ColumnHasVisiblePixels(bitmap, x)) 108 if (ColumnHasVisiblePixels(bitmap, x))
99 break; 109 break;
100 } 110 }
101 *right = bitmap.width() - 1 - x; 111 *right = bitmap.width() - 1 - x;
102 } 112 }
103 113
104 } // namespace gfx 114 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_util.h ('k') | ui/gfx/image/image_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698