forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_image.h
178 lines (148 loc) · 5.23 KB
/
_image.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/* -*- mode: c++; c-basic-offset: 4 -*- */
/* image.h
*
*/
#ifndef _IMAGE_H
#define _IMAGE_H
#include <utility>
#include "Python.h"
#include "agg_trans_affine.h"
#include "agg_rendering_buffer.h"
#include "agg_color_rgba.h"
#include "CXX/Extensions.hxx"
class Image : public Py::PythonExtension<Image>
{
public:
Image();
virtual ~Image();
static void init_type(void);
int setattr(const char*, const Py::Object &);
Py::Object getattr(const char * name);
Py::Object apply_rotation(const Py::Tuple& args);
Py::Object apply_scaling(const Py::Tuple& args);
Py::Object apply_translation(const Py::Tuple& args);
Py::Object as_rgba_str(const Py::Tuple& args, const Py::Dict& kwargs);
Py::Object color_conv(const Py::Tuple& args);
Py::Object buffer_rgba(const Py::Tuple& args);
Py::Object reset_matrix(const Py::Tuple& args);
Py::Object get_matrix(const Py::Tuple& args);
Py::Object resize(const Py::Tuple& args, const Py::Dict& kwargs);
Py::Object get_aspect(const Py::Tuple& args);
Py::Object get_size(const Py::Tuple& args);
Py::Object get_size_out(const Py::Tuple& args);
Py::Object get_interpolation(const Py::Tuple& args);
Py::Object set_interpolation(const Py::Tuple& args);
Py::Object set_aspect(const Py::Tuple& args);
Py::Object set_bg(const Py::Tuple& args);
inline Py::Object flipud_out(const Py::Tuple& args)
{
args.verify_length(0);
int stride = rbufOut->stride();
//std::cout << "flip before: " << rbufOut->stride() << std::endl;
rbufOut->attach(bufferOut, colsOut, rowsOut, -stride);
//std::cout << "flip after: " << rbufOut->stride() << std::endl;
return Py::Object();
}
Py::Object flipud_in(const Py::Tuple& args);
Py::Object set_resample(const Py::Tuple& args);
Py::Object get_resample(const Py::Tuple& args);
std::pair<agg::int8u*, bool> _get_output_buffer();
enum {NEAREST,
BILINEAR,
BICUBIC,
SPLINE16,
SPLINE36,
HANNING,
HAMMING,
HERMITE,
KAISER,
QUADRIC,
CATROM,
GAUSSIAN,
BESSEL,
MITCHELL,
SINC,
LANCZOS,
BLACKMAN
};
//enum { BICUBIC=0, BILINEAR, BLACKMAN100, BLACKMAN256, BLACKMAN64,
// NEAREST, SINC144, SINC256, SINC64, SPLINE16, SPLINE36};
enum { ASPECT_PRESERVE = 0, ASPECT_FREE};
agg::int8u *bufferIn;
agg::rendering_buffer *rbufIn;
size_t colsIn, rowsIn;
agg::int8u *bufferOut;
agg::rendering_buffer *rbufOut;
size_t colsOut, rowsOut;
unsigned BPP;
unsigned interpolation, aspect;
agg::rgba bg;
bool resample;
private:
Py::Dict __dict__;
agg::trans_affine srcMatrix, imageMatrix;
static char apply_rotation__doc__[];
static char apply_scaling__doc__[];
static char apply_translation__doc__[];
static char as_rgba_str__doc__[];
static char color_conv__doc__[];
static char buffer_rgba__doc__[];
static char reset_matrix__doc__[];
static char get_matrix__doc__[];
static char resize__doc__[];
static char get_aspect__doc__[];
static char get_size__doc__[];
static char get_size_out__doc__[];
static char get_interpolation__doc__[];
static char set_interpolation__doc__[];
static char set_aspect__doc__[];
static char set_bg__doc__[];
static char flipud_out__doc__[];
static char flipud_in__doc__[];
static char get_resample__doc__[];
static char set_resample__doc__[];
};
/*
class ImageComposite : public Py::PythonExtension<ImageComposite> {
}
*/
// the extension module
class _image_module : public Py::ExtensionModule<_image_module>
{
public:
_image_module() : Py::ExtensionModule<_image_module>("_image")
{
Image::init_type();
add_varargs_method("fromarray", &_image_module::fromarray,
"fromarray");
add_varargs_method("fromarray2", &_image_module::fromarray2,
"fromarray2");
add_varargs_method("frombyte", &_image_module::frombyte,
"frombyte");
add_varargs_method("frombuffer", &_image_module::frombuffer,
"frombuffer");
add_varargs_method("from_images", &_image_module::from_images,
"from_images");
add_varargs_method("pcolor", &_image_module::pcolor,
"pcolor");
add_varargs_method("pcolor2", &_image_module::pcolor2,
"pcolor2");
initialize("The _image module");
}
~_image_module() {}
private:
Py::Object frombyte(const Py::Tuple &args);
Py::Object frombuffer(const Py::Tuple &args);
Py::Object fromarray(const Py::Tuple &args);
Py::Object fromarray2(const Py::Tuple &args);
Py::Object pcolor(const Py::Tuple &args);
Py::Object pcolor2(const Py::Tuple &args);
Py::Object from_images(const Py::Tuple &args);
static char _image_module_fromarray__doc__[];
static char _image_module_pcolor__doc__[];
static char _image_module_pcolor2__doc__[];
static char _image_module_fromarray2__doc__[];
static char _image_module_frombyte__doc__[];
static char _image_module_frombuffer__doc__[];
};
#endif