blob: 3d734d6efc5a2dded5836975165941dabce10112 [file] [log] [blame]
humper@google.com138ebc32013-07-19 20:20:04 +00001/*
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 */
skia.committer@gmail.com1f3c7382013-07-20 07:00:58 +00007
humper@google.com138ebc32013-07-19 20:20:04 +00008#ifndef SkBitmapScaler_DEFINED
9#define SkBitmapScaler_DEFINED
10
11#include "SkBitmap.h"
12#include "SkConvolver.h"
skia.committer@gmail.com1f3c7382013-07-20 07:00:58 +000013
humper@google.com138ebc32013-07-19 20:20:04 +000014/** \class SkBitmapScaler
15
16 Provides the interface for high quality image resampling.
17 */
skia.committer@gmail.com1f3c7382013-07-20 07:00:58 +000018
humper@google.com138ebc32013-07-19 20:20:04 +000019class SK_API SkBitmapScaler {
skia.committer@gmail.com1f3c7382013-07-20 07:00:58 +000020public:
humper@google.com138ebc32013-07-19 20:20:04 +000021 enum ResizeMethod {
humper@google.com138ebc32013-07-19 20:20:04 +000022 RESIZE_BOX,
23 RESIZE_TRIANGLE,
24 RESIZE_LANCZOS3,
25 RESIZE_HAMMING,
26 RESIZE_MITCHELL,
skia.committer@gmail.com1f3c7382013-07-20 07:00:58 +000027
reed99138872015-08-31 15:16:17 -070028 RESIZE_FirstMethod = RESIZE_BOX,
29 RESIZE_LastMethod = RESIZE_MITCHELL,
humper@google.com138ebc32013-07-19 20:20:04 +000030 };
skia.committer@gmail.com1f3c7382013-07-20 07:00:58 +000031
reed97c40072016-01-13 13:36:31 -080032 /**
33 * Given already-allocated src and dst pixmaps, this will scale the src pixels using the
34 * specified resize-method and write the results into the pixels pointed to by dst.
35 */
36 static bool Resize(const SkPixmap& dst, const SkPixmap& src, ResizeMethod method);
37
38 /**
39 * Helper function that manages allocating a bitmap to hold the dst pixels, and then calls
40 * the pixmap version of Resize.
41 */
reed3c834322015-06-12 07:09:59 -070042 static bool Resize(SkBitmap* result, const SkPixmap& src, ResizeMethod method,
reed99138872015-08-31 15:16:17 -070043 int dest_width, int dest_height, SkBitmap::Allocator* = nullptr);
humper4f96ab32014-06-27 11:27:03 -070044
45 /** Platforms can also optionally overwrite the convolution functions
46 if we have SIMD versions of them.
47 */
48
49 static void PlatformConvolutionProcs(SkConvolutionProcs*);
humper@google.com138ebc32013-07-19 20:20:04 +000050};
51
52#endif