2 #include "colormodels.h"
6 #include "flipwindow.h"
13 #define _(String) gettext(String)
14 #define gettext_noop(String) String
15 #define N_(String) gettext_noop (String)
17 REGISTER_PLUGIN(FlipMain)
24 FlipConfig::FlipConfig()
30 void FlipConfig::copy_from(FlipConfig &that)
32 flip_horizontal = that.flip_horizontal;
33 flip_vertical = that.flip_vertical;
36 int FlipConfig::equivalent(FlipConfig &that)
38 return flip_horizontal == that.flip_horizontal &&
39 flip_vertical == that.flip_vertical;
42 void FlipConfig::interpolate(FlipConfig &prev,
48 this->flip_horizontal = prev.flip_horizontal;
49 this->flip_vertical = prev.flip_vertical;
61 FlipMain::FlipMain(PluginServer *server)
62 : PluginVClient(server)
64 PLUGIN_CONSTRUCTOR_MACRO
69 PLUGIN_DESTRUCTOR_MACRO
72 char* FlipMain::plugin_title() { return _("Flip"); }
73 int FlipMain::is_realtime() { return 1; }
76 #define SWAP_PIXELS(components, in, out) \
98 #define FLIP_MACRO(type, components) \
100 type **input_rows, **output_rows; \
101 type *input_row, *output_row; \
102 input_rows = ((type**)input_ptr->get_rows()); \
103 output_rows = ((type**)output_ptr->get_rows()); \
105 if(config.flip_vertical) \
107 for(i = 0, j = h - 1; i < h / 2; i++, j--) \
109 input_row = input_rows[i]; \
110 output_row = output_rows[j]; \
111 for(k = 0; k < w; k++) \
113 SWAP_PIXELS(components, output_row, input_row); \
114 output_row += components; \
115 input_row += components; \
120 if(config.flip_horizontal) \
122 for(i = 0; i < h; i++) \
124 input_row = input_rows[i]; \
125 output_row = output_rows[i] + (w - 1) * components; \
126 for(k = 0; k < w / 2; k++) \
128 SWAP_PIXELS(components, output_row, input_row); \
129 input_row += components; \
130 output_row -= components; \
136 int FlipMain::process_realtime(VFrame *input_ptr, VFrame *output_ptr)
139 int w = input_ptr->get_w();
140 int h = input_ptr->get_h();
141 int colormodel = input_ptr->get_color_model();
143 load_configuration();
148 FLIP_MACRO(unsigned char, 3);
152 FLIP_MACRO(uint16_t, 3);
156 FLIP_MACRO(unsigned char, 4);
158 case BC_RGBA16161616:
159 case BC_YUVA16161616:
160 FLIP_MACRO(uint16_t, 4);
167 SHOW_GUI_MACRO(FlipMain, FlipThread)
169 RAISE_WINDOW_MACRO(FlipMain)
171 SET_STRING_MACRO(FlipMain)
173 NEW_PICON_MACRO(FlipMain)
175 LOAD_CONFIGURATION_MACRO(FlipMain, FlipConfig)
177 void FlipMain::update_gui()
181 load_configuration();
182 thread->window->lock_window();
183 thread->window->flip_vertical->update((int)config.flip_vertical);
184 thread->window->flip_horizontal->update((int)config.flip_horizontal);
185 thread->window->unlock_window();
189 void FlipMain::save_data(KeyFrame *keyframe)
193 // cause data to be stored directly in text
194 output.set_shared_string(keyframe->data, MESSAGESIZE);
195 output.tag.set_title("FLIP");
197 if(config.flip_vertical)
199 output.tag.set_title("VERTICAL");
203 if(config.flip_horizontal)
205 output.tag.set_title("HORIZONTAL");
208 output.terminate_string();
209 // data is now in *text
212 void FlipMain::read_data(KeyFrame *keyframe)
216 input.set_shared_string(keyframe->data, strlen(keyframe->data));
219 config.flip_vertical = config.flip_horizontal = 0;
223 result = input.read_tag();
227 if(input.tag.title_is("VERTICAL"))
229 config.flip_vertical = 1;
232 if(input.tag.title_is("HORIZONTAL"))
234 config.flip_horizontal = 1;
240 int FlipMain::load_defaults()
242 char directory[BCTEXTLEN], string[BCTEXTLEN];
243 // set the default directory
244 sprintf(directory, "%sflip.rc", BCASTDIR);
247 defaults = new Defaults(directory);
250 config.flip_horizontal = defaults->get("FLIP_HORIZONTAL", config.flip_horizontal);
251 config.flip_vertical = defaults->get("FLIP_VERTICAL", config.flip_vertical);
255 int FlipMain::save_defaults()
257 defaults->update("FLIP_HORIZONTAL", config.flip_horizontal);
258 defaults->update("FLIP_VERTICAL", config.flip_vertical);