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

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

Issue 148093013: [gfx] Add a utility to calculate visible margins of an image. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/gfx/image/image_util.cc » ('j') | ui/gfx/image/image_util.cc » ('J')
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 #ifndef UI_GFX_IMAGE_IMAGE_UTIL_H_ 5 #ifndef UI_GFX_IMAGE_IMAGE_UTIL_H_
6 #define UI_GFX_IMAGE_IMAGE_UTIL_H_ 6 #define UI_GFX_IMAGE_IMAGE_UTIL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "ui/gfx/gfx_export.h" 11 #include "ui/gfx/gfx_export.h"
12 12
13 namespace gfx { 13 namespace gfx {
14 class Image; 14 class Image;
15 class ImageSkia;
15 } 16 }
16 17
17 namespace gfx { 18 namespace gfx {
18 19
19 // Creates an image from the given JPEG-encoded input. If there was an error 20 // Creates an image from the given JPEG-encoded input. If there was an error
20 // creating the image, returns an IsEmpty() Image. 21 // creating the image, returns an IsEmpty() Image.
21 GFX_EXPORT Image ImageFrom1xJPEGEncodedData(const unsigned char* input, 22 GFX_EXPORT Image ImageFrom1xJPEGEncodedData(const unsigned char* input,
22 size_t input_size); 23 size_t input_size);
23 24
24 // Fills the |dst| vector with JPEG-encoded bytes of the 1x representation of 25 // Fills the |dst| vector with JPEG-encoded bytes of the 1x representation of
25 // the given image. 26 // the given image.
26 // Returns true if the image has a 1x representation and the 1x representation 27 // Returns true if the image has a 1x representation and the 1x representation
27 // was encoded successfully. 28 // was encoded successfully.
28 // |quality| determines the compression level, 0 == lowest, 100 == highest. 29 // |quality| determines the compression level, 0 == lowest, 100 == highest.
29 // Returns true if the Image was encoded successfully. 30 // Returns true if the Image was encoded successfully.
30 GFX_EXPORT bool JPEG1xEncodedDataFromImage(const Image& image, 31 GFX_EXPORT bool JPEG1xEncodedDataFromImage(const Image& image,
31 int quality, 32 int quality,
32 std::vector<unsigned char>* dst); 33 std::vector<unsigned char>* dst);
33 34
35 // Returns the visible (non-transparent) width of the 1x rep of the given
36 // image. If the image has no transparency, the leading value will be 0 and
37 // the trailing will be the image width. Return values are in the 1x width
38 // pixel units. Margins are given in 0-based column format. So if the image
39 // has only transparent pixels in columns 0, 1, 2, 3, then the leading value
40 // will be 4. Similarly, if there are all transparent pixels in column
41 // width-2, width-1, then the trailing margin value will be width-3.
42 // Returns true if the value is computed from opacity, false if it is a
43 // default value because of null image, missing Rep, etc.
44 // This method is only suitable for fairly small images (i.e. 16x16).
45 // The margins for a completely transparent image will be w/2-1, w/2, but this
46 // will be an expensive operation: it isn't expected that it will be frequently
47 // calculated.
48 GFX_EXPORT bool VisibleMargins(const ImageSkia& image,
49 int* leading, int* trailing);
50
34 } // namespace gfx 51 } // namespace gfx
35 52
36 #endif // UI_GFX_IMAGE_IMAGE_UTIL_H_ 53 #endif // UI_GFX_IMAGE_IMAGE_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/image/image_util.cc » ('j') | ui/gfx/image/image_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698