-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathFl_ImageC.cpp
172 lines (171 loc) · 6.02 KB
/
Fl_ImageC.cpp
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
#include "Fl_ImageC.h"
#ifdef __cplusplus
Fl_DerivedImage::Fl_DerivedImage(int W, int H, int D, fl_Image_Virtual_Funcs* fs) : Fl_Image(W,H,D){
overriddenFuncs = fs;
other_data = 0;
}
Fl_DerivedImage::~Fl_DerivedImage(){
destroy_data();
free(overriddenFuncs);
}
void* Fl_DerivedImage::get_other_data(){
return this->other_data;
}
void Fl_DerivedImage::set_other_data(void* data){
this->other_data = data;
}
void Fl_DerivedImage::destroy_data(){
if (this->overriddenFuncs->destroy_data != NULL){
fl_DoNotCall* fps = NULL;
int num_fps = C_to_Fl_Callback::function_pointers_to_free(this->overriddenFuncs,&fps);
Function_Pointers_To_Free* res = C_to_Fl_Callback::gather_function_pointers(num_fps,num_fps,fps);
this->overriddenFuncs->destroy_data((fl_Image)this,res);
if (fps) { free(fps); }
free(res);
}
}
void Fl_DerivedImage::color_average(Fl_Color c, float i){
if (overriddenFuncs->color_average){
this->overriddenFuncs->color_average((fl_Image) this,c, i );
}
else {
Fl_Image::color_average(c,i);
}
}
Fl_Image* Fl_DerivedImage::copy(){
return Fl_Image::copy();
}
Fl_Image* Fl_DerivedImage::copy(int W, int H){
if (overriddenFuncs->copy){
fl_Image image = (fl_Image)this->overriddenFuncs->copy((fl_Image) this, W, H);
return (static_cast<Fl_Image*>(image));
}
else {
return Fl_Image::copy(W, H);
}
};
void Fl_DerivedImage::desaturate(){
if (this->overriddenFuncs->desaturate){
this->overriddenFuncs->desaturate((fl_Image) this);
}
else {
Fl_Image::desaturate();
}
}
void Fl_DerivedImage::draw(int X, int Y, int W, int H, int cx, int cy){
if (overriddenFuncs->draw){
this->overriddenFuncs->draw((fl_Image) this,X,Y,W,H,cx,cy);
}
else {
Fl_Image::draw(X,Y,W,H,cx,cy);
}
}
void Fl_DerivedImage::uncache(){
if (overriddenFuncs->uncache){
this->overriddenFuncs->uncache((fl_Image) this);
}
else {
Fl_Image::uncache();
}
}
EXPORT {
#endif
FL_EXPORT_C(fl_Image_Virtual_Funcs*, Fl_Image_default_virtual_funcs)(){
fl_Image_Virtual_Funcs* ptr = (fl_Image_Virtual_Funcs*)malloc(sizeof(fl_Image_Virtual_Funcs));
ptr->draw = NULL;
ptr->color_average = NULL;
ptr->copy = NULL;
ptr->desaturate = NULL;
ptr->uncache = NULL;
ptr->destroy_data = NULL;
return ptr;
}
FL_EXPORT_C(void*, Fl_Image_other_data)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->get_other_data();
}
FL_EXPORT_C(void, Fl_Image_set_other_data)(fl_Image image, void* v){
(static_cast<Fl_DerivedImage*>(image))->set_other_data(v);
}
FL_EXPORT_C(fl_Image, Fl_Image_New)(int W, int H, int D){
fl_Image_Virtual_Funcs* fs = Fl_Image_default_virtual_funcs();
Fl_DerivedImage* d = new Fl_DerivedImage(W,H,D,fs);
return (fl_Image)d;
}
FL_EXPORT_C(fl_Image, Fl_OverriddenImage_New)(int W, int H, int D, fl_Image_Virtual_Funcs* funcs){
Fl_DerivedImage* d = new Fl_DerivedImage(W,H,D,funcs);
return (fl_Image)d;
}
FL_EXPORT_C(void, Fl_Image_Destroy)(fl_Image image) {
delete (static_cast<Fl_Image*>(image));
}
FL_EXPORT_C(int,Fl_Image_w)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->w();
}
FL_EXPORT_C(int,Fl_Image_h)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->h();
}
FL_EXPORT_C(int,Fl_Image_d)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->d();
}
FL_EXPORT_C(int,Fl_Image_ld)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->ld();
}
FL_EXPORT_C(int,Fl_Image_count)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->count();
}
FL_EXPORT_C(fl_Image,Fl_Image_copy_with_w_h)(fl_Image image,int W,int H){
return (fl_Image)(static_cast<Fl_DerivedImage*>(image))->copy(W,H);
}
FL_EXPORT_C(fl_Image,Fl_Image_copy)(fl_Image image){
return (fl_Image)(static_cast<Fl_DerivedImage*>(image))->copy();
}
FL_EXPORT_C(void,Fl_Image_color_average)(fl_Image image,Fl_Color c,float i){
return (static_cast<Fl_DerivedImage*>(image))->color_average(c,i);
}
FL_EXPORT_C(void,Fl_Image_inactive)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->inactive();
}
FL_EXPORT_C(void,Fl_Image_desaturate)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->desaturate();
}
FL_EXPORT_C(void,Fl_Image_label)(fl_Image image,fl_Widget w){
return (static_cast<Fl_DerivedImage*>(image))->label((static_cast<Fl_Widget*>(w)));
}
FL_EXPORT_C(void,Fl_Image_label_with_menu_item)(fl_Image image,fl_Menu_Item m){
return (static_cast<Fl_DerivedImage*>(image))->label((static_cast<Fl_Menu_Item*>(m)));
}
FL_EXPORT_C(void,Fl_Image_draw_with_cx_cy)(fl_Image image,int X,int Y,int W,int H,int cx,int cy){
return (static_cast<Fl_DerivedImage*>(image))->draw(X,Y,W,H,cx,cy);
}
FL_EXPORT_C(void,Fl_Image_draw_with_cx)(fl_Image image,int X,int Y,int W,int H,int cx){
return (static_cast<Fl_DerivedImage*>(image))->draw(X,Y,W,H,cx);
}
FL_EXPORT_C(void,Fl_Image_draw_with_cy)(fl_Image image,int X,int Y,int W,int H,int cy){
return (static_cast<Fl_DerivedImage*>(image))->draw(X,Y,W,H,0,cy);
}
FL_EXPORT_C(void,Fl_Image_draw_with)(fl_Image image,int X,int Y,int W,int H){
return (static_cast<Fl_DerivedImage*>(image))->draw(X,Y,W,H);
}
FL_EXPORT_C(void,Fl_Image_draw)(fl_Image image,int X,int Y){
return (static_cast<Fl_Image*>(image))->draw(X,Y);
}
FL_EXPORT_C(void,Fl_Image_uncache)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->uncache();
}
#if FL_API_VERSION >= 10304
FL_EXPORT_C(int, Fl_Image_fail)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->fail();
}
FL_EXPORT_C(void,Fl_Image_scale)(fl_Image image, int w, int h, int proportional, int can_expand){
(static_cast<Fl_DerivedImage*>(image))->scale(w,h,proportional,can_expand);
};
FL_EXPORT_C(int,Fl_Image_data_w)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->data_w();
};
FL_EXPORT_C(int,Fl_Image_data_h)(fl_Image image){
return (static_cast<Fl_DerivedImage*>(image))->data_h();
};
#endif
#ifdef __cplusplus
}
#endif