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

Side by Side Diff: src/core/SkBitmapScaler.h

Issue 19335002: Production quality fast image up/downsampler (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: camel case and if-statement braces Created 7 years, 5 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 | « src/core/SkBitmapProcState.cpp ('k') | src/core/SkBitmapScaler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkBitmapScaler_DEFINED
9 #define SkBitmapScaler_DEFINED
10
11 #include "SkBitmap.h"
12 #include "SkConvolver.h"
13
14 /** \class SkBitmapScaler
15
16 Provides the interface for high quality image resampling.
17 */
18
19 class SK_API SkBitmapScaler {
20 public:
21 enum ResizeMethod {
22 // Quality Methods
23 //
24 // Those enumeration values express a desired quality/speed tradeoff.
25 // They are translated into an algorithm-specific method that depends
26 // on the capabilities (CPU, GPU) of the underlying platform.
27 // It is possible for all three methods to be mapped to the same
28 // algorithm on a given platform.
29
30 // Good quality resizing. Fastest resizing with acceptable visual qualit y.
31 // This is typically intended for use during interactive layouts
32 // where slower platforms may want to trade image quality for large
33 // increase in resizing performance.
34 //
35 // For example the resizing implementation may devolve to linear
36 // filtering if this enables GPU acceleration to be used.
37 //
38 // Note that the underlying resizing method may be determined
39 // on the fly based on the parameters for a given resize call.
40 // For example an implementation using a GPU-based linear filter
41 // in the common case may still use a higher-quality software-based
42 // filter in cases where using the GPU would actually be slower - due
43 // to too much latency - or impossible - due to image format or size
44 // constraints.
45 RESIZE_GOOD,
46
47 // Medium quality resizing. Close to high quality resizing (better
48 // than linear interpolation) with potentially some quality being
49 // traded-off for additional speed compared to RESIZE_BEST.
50 //
51 // This is intended, for example, for generation of large thumbnails
52 // (hundreds of pixels in each dimension) from large sources, where
53 // a linear filter would produce too many artifacts but where
54 // a RESIZE_HIGH might be too costly time-wise.
55 RESIZE_BETTER,
56
57 // High quality resizing. The algorithm is picked to favor image quality .
58 RESIZE_BEST,
59
60 //
61 // Algorithm-specific enumerations
62 //
63
64 // Box filter. This is a weighted average of all of the pixels touching
65 // the destination pixel. For enlargement, this is nearest neighbor.
66 //
67 // You probably don't want this, it is here for testing since it is easy to
68 // compute. Use RESIZE_LANCZOS3 instead.
69 RESIZE_BOX,
70 RESIZE_TRIANGLE,
71 RESIZE_LANCZOS3,
72 RESIZE_HAMMING,
73 RESIZE_MITCHELL,
74
75 // enum aliases for first and last methods by algorithm or by quality.
76 RESIZE_FIRST_QUALITY_METHOD = RESIZE_GOOD,
77 RESIZE_LAST_QUALITY_METHOD = RESIZE_BEST,
78 RESIZE_FIRST_ALGORITHM_METHOD = RESIZE_BOX,
79 RESIZE_LAST_ALGORITHM_METHOD = RESIZE_MITCHELL,
80 };
81
82 // Resizes the given source bitmap using the specified resize method, so tha t
83 // the entire image is (dest_size) big. The dest_subset is the rectangle in
84 // this destination image that should actually be returned.
85 //
86 // The output image will be (dest_subset.width(), dest_subset.height()). Thi s
87 // will save work if you do not need the entire bitmap.
88 //
89 // The destination subset must be smaller than the destination image.
90 static SkBitmap Resize(const SkBitmap& source,
91 ResizeMethod method,
92 int dest_width, int dest_height,
93 const SkIRect& dest_subset,
94 SkConvolutionProcs *convolveProcs = NULL,
95 SkBitmap::Allocator* allocator = NULL);
96
97 // Alternate version for resizing and returning the entire bitmap rather tha n
98 // a subset.
99 static SkBitmap Resize(const SkBitmap& source,
100 ResizeMethod method,
101 int dest_width, int dest_height,
102 SkConvolutionProcs *convolveProcs = NULL,
103 SkBitmap::Allocator* allocator = NULL);
104 };
105
106 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | src/core/SkBitmapScaler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698