• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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         RESIZE_BOX,
23         RESIZE_TRIANGLE,
24         RESIZE_LANCZOS3,
25         RESIZE_HAMMING,
26         RESIZE_MITCHELL,
27 
28         RESIZE_FirstMethod = RESIZE_BOX,
29         RESIZE_LastMethod = RESIZE_MITCHELL,
30     };
31 
32     /**
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      */
42     static bool Resize(SkBitmap* result, const SkPixmap& src, ResizeMethod method,
43                        int dest_width, int dest_height, SkBitmap::Allocator* = nullptr);
44 };
45 
46 #endif
47