aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapScaler.h
blob: c96be0dbf8cc2e73e69b30ff4938e5f5ff018ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkBitmapScaler_DEFINED
#define SkBitmapScaler_DEFINED

#include "SkBitmap.h"
#include "SkConvolver.h"

/** \class SkBitmapScaler

    Provides the interface for high quality image resampling.
 */

class SK_API SkBitmapScaler {
public:
    enum ResizeMethod {
        RESIZE_BOX,
        RESIZE_TRIANGLE,
        RESIZE_LANCZOS3,
        RESIZE_HAMMING,
        RESIZE_MITCHELL,

        RESIZE_FirstMethod = RESIZE_BOX,
        RESIZE_LastMethod = RESIZE_MITCHELL,
    };

    /**
     *  Given already-allocated src and dst pixmaps, this will scale the src pixels using the
     *  specified resize-method and write the results into the pixels pointed to by dst.
     */
    static bool Resize(const SkPixmap& dst, const SkPixmap& src, ResizeMethod method);

    /**
     *  Helper function that manages allocating a bitmap to hold the dst pixels, and then calls
     *  the pixmap version of Resize.
     */
    static bool Resize(SkBitmap* result, const SkPixmap& src, ResizeMethod method,
                       int dest_width, int dest_height, SkBitmap::Allocator* = nullptr);
};

#endif