{
this->window = window;
this->plugin = plugin;
- set_precision(0.01);
+ set_precision(0.1);
set_use_caption(0);
}
int y)
: BC_TextBox(x,
y,
- 90,
+ xS(90),
1,
(float)plugin->config.angle)
{
RotateWindow::RotateWindow(RotateEffect *plugin)
- : PluginClientWindow(plugin,
- 250,
- 230,
- 250,
- 230,
- 0)
+ : PluginClientWindow(plugin, xS(300), yS(230), xS(300), yS(230), 0)
{
this->plugin = plugin;
}
-#define RADIUS 30
+#define RADIUS xS(30)
void RotateWindow::create_objects()
{
- int x = 10, y = 10;
+ int xs10 = xS(10), xs50 = xS(50), xs150 = xS(150);
+ int ys10 = yS(10), ys20 = yS(20), ys25 = yS(25), ys50 = yS(50), ys60 = yS(60);
+ int x = xs10, y = ys10;
BC_Title *title;
-
-
-
add_tool(new BC_Title(x, y, _("Rotate")));
- x += 50;
- y += 20;
- add_tool(toggle0 = new RotateToggle(this,
- plugin,
- plugin->config.angle == 0,
- x,
- y,
- 0,
- "0"));
- x += RADIUS;
- y += RADIUS;
- add_tool(toggle90 = new RotateToggle(this,
- plugin,
- plugin->config.angle == 90,
- x,
- y,
- 90,
- "90"));
- x -= RADIUS;
- y += RADIUS;
- add_tool(toggle180 = new RotateToggle(this,
- plugin,
- plugin->config.angle == 180,
- x,
- y,
- 180,
- "180"));
- x -= RADIUS;
- y -= RADIUS;
- add_tool(toggle270 = new RotateToggle(this,
- plugin,
- plugin->config.angle == 270,
- x,
- y,
- 270,
- "270"));
-// add_subwindow(bilinear = new RotateInterpolate(plugin, 10, y + 60));
- x += 120;
- y -= 50;
+ x += xs50; y += ys20;
+ add_tool(toggle0 = new RotateToggle(this, plugin,
+ plugin->config.angle == 0, x, y, 0, "0"));
+ x += RADIUS; y += RADIUS;
+ add_tool(toggle90 = new RotateToggle(this, plugin,
+ plugin->config.angle == 90, x, y, 90, "90"));
+ x -= RADIUS; y += RADIUS;
+ add_tool(toggle180 = new RotateToggle(this, plugin,
+ plugin->config.angle == 180, x, y, 180, "180"));
+ x -= RADIUS; y -= RADIUS;
+ add_tool(toggle270 = new RotateToggle(this, plugin,
+ plugin->config.angle == 270, x, y, 270, "270"));
+// add_subwindow(bilinear = new RotateInterpolate(plugin, xs10, y + ys60));
+ x += xs150; y -= ys50;
add_tool(fine = new RotateFine(this, plugin, x, y));
- y += fine->get_h() + 10;
+ y += fine->get_h() + ys10;
add_tool(text = new RotateText(this, plugin, x, y));
- y += 25;
+ y += ys25;
add_tool(new BC_Title(x, y, _("Degrees")));
-
-
-
-
- y += text->get_h() + 10;
+ y += text->get_h() + ys10;
add_subwindow(title = new BC_Title(x, y, _("Pivot (x,y):")));
- y += title->get_h() + 10;
+ y += title->get_h() + ys10;
add_subwindow(this->x = new RotateX(this, plugin, x, y));
- x += this->x->get_w() + 10;
+ x += this->x->get_w() + xs10;
add_subwindow(this->y = new RotateY(this, plugin, x, y));
-// y += this->y->get_h() + 10;
- x = 10;
+// y += this->y->get_h() + ys10;
+ x = xs10;
add_subwindow(draw_pivot = new RotateDrawPivot(this, plugin, x, y));
- y += 60;
+ y += ys60;
add_subwindow(reset = new RotateReset(plugin, this, x, y));
show_window();
double frame_rate)
{
load_configuration();
- int w = frame->get_w();
- int h = frame->get_h();
//printf("RotateEffect::process_buffer %d\n", __LINE__);
- if(config.angle == 0)
+ if(config.angle == 0 && !config.draw_pivot)
{
read_frame(frame,
0,
//printf("RotateEffect::process_buffer %d draw_pivot=%d\n", __LINE__, config.draw_pivot);
// Draw center
-#define CENTER_H 20
-#define CENTER_W 20
-#define DRAW_CENTER(components, type, max) \
-{ \
- type **rows = (type**)get_output()->get_rows(); \
- if( (center_x >= 0 && center_x < w) || (center_y >= 0 && center_y < h) ) \
- { \
- type *hrow = rows[center_y] + components * (center_x - CENTER_W / 2); \
- for(int i = center_x - CENTER_W / 2; i <= center_x + CENTER_W / 2; i++) \
- { \
- if(i >= 0 && i < w) \
- { \
- hrow[0] = max - hrow[0]; \
- hrow[1] = max - hrow[1]; \
- hrow[2] = max - hrow[2]; \
- hrow += components; \
- } \
- } \
- \
- for(int i = center_y - CENTER_W / 2; i <= center_y + CENTER_W / 2; i++) \
- { \
- if(i >= 0 && i < h) \
- { \
- type *vrow = rows[i] + center_x * components; \
- vrow[0] = max - vrow[0]; \
- vrow[1] = max - vrow[1]; \
- vrow[2] = max - vrow[2]; \
- } \
- } \
- } \
-}
-
- if(config.draw_pivot)
- {
- int center_x = (int)(config.pivot_x * w / 100); \
- int center_y = (int)(config.pivot_y * h / 100); \
-
-//printf("RotateEffect::process_buffer %d %d %d\n", __LINE__, center_x, center_y);
- switch(get_output()->get_color_model())
- {
- case BC_RGB_FLOAT:
- DRAW_CENTER(3, float, 1.0)
- break;
- case BC_RGBA_FLOAT:
- DRAW_CENTER(4, float, 1.0)
- break;
- case BC_RGB888:
- DRAW_CENTER(3, unsigned char, 0xff)
- break;
- case BC_RGBA8888:
- DRAW_CENTER(4, unsigned char, 0xff)
- break;
- case BC_YUV888:
- DRAW_CENTER(3, unsigned char, 0xff)
- break;
- case BC_YUVA8888:
- DRAW_CENTER(4, unsigned char, 0xff)
- break;
- }
+ if(config.draw_pivot) {
+ VFrame *vframe = get_output();
+ int w = vframe->get_w(), h = vframe->get_h();
+ int mx = w > h ? w : h;
+ int lw = mx/400 + 1, cxy = mx/80;
+ int center_x = (int)(config.pivot_x * w/100);
+ int center_y = (int)(config.pivot_y * h/100);
+ int x1 = center_x - cxy, x2 = center_x + cxy;
+ int y1 = center_y - cxy, y2 = center_y + cxy;
+ vframe->set_pixel_color(WHITE);
+ for( int i=0; i<lw; ++i )
+ frame->draw_line(x1-i,center_y-i, x2-i,center_y-i);
+ vframe->set_pixel_color(BLACK);
+ for( int i=1; i<=lw; ++i )
+ frame->draw_line(x1+i,center_y+i, x2+i,center_y+i);
+ vframe->set_pixel_color(WHITE);
+ for( int i=0; i<lw; ++i )
+ frame->draw_line(center_x-i,y1-i, center_x-i,y2-i);
+ vframe->set_pixel_color(BLACK);
+ for( int i=1; i<=lw; ++i )
+ frame->draw_line(center_x+i,y1+i, center_x+i,y2+i);
}
// Conserve memory by deleting large frames
if(config.draw_pivot)
{
- int w = get_output()->get_w();
- int h = get_output()->get_h();
- int center_x = (int)(config.pivot_x * w / 100);
- int center_y = (int)(config.pivot_y * h / 100);
-
+ VFrame *vframe = get_output();
+ int w = vframe->get_w(), h = vframe->get_h();
+ int mx = w > h ? w : h;
+ int lw = mx/400 + 1, cxy = mx/80;
+ int center_x = (int)(config.pivot_x * w/100);
+ int center_y = (int)(config.pivot_y * h/100);
+ int x1 = center_x - cxy, x2 = center_x + cxy;
+ int y1 = center_y - cxy, y2 = center_y + cxy;
glDisable(GL_TEXTURE_2D);
- glColor4f(0.0, 0.0, 0.0, 1.0);
- glBegin(GL_LINES);
- glVertex3f(center_x, -h + center_y - CENTER_H / 2, 0.0);
- glVertex3f(center_x, -h + center_y + CENTER_H / 2, 0.0);
- glEnd();
+ int is_yuv = BC_CModels::is_yuv(vframe->get_color_model());
+ float rwt = 1, gwt = is_yuv? 0.5 : 1, bwt = is_yuv? 0.5 : 1;
+ float rbk = 0, gbk = is_yuv? 0.5 : 0, bbk = is_yuv? 0.5 : 0;
glBegin(GL_LINES);
- glVertex3f(center_x - CENTER_W / 2, -h + center_y, 0.0);
- glVertex3f(center_x + CENTER_W / 2, -h + center_y, 0.0);
- glEnd();
- glColor4f(1.0, 1.0, 1.0, 1.0);
- glBegin(GL_LINES);
- glVertex3f(center_x - 1, -h + center_y - CENTER_H / 2 - 1, 0.0);
- glVertex3f(center_x - 1, -h + center_y + CENTER_H / 2 - 1, 0.0);
+ glColor4f(rwt, gwt, bwt, 1.0);
+ for( int i=0; i<lw; ++i ) {
+ glVertex3f(x1-i, center_y-i - h, 0.0);
+ glVertex3f(x2-i, center_y-i - h, 0.0);
+ }
+ glColor4f(rbk, gbk, bbk, 1.0);
+ for( int i=1; i<=lw; ++i ) {
+ glVertex3f(x1+i, center_y+i - h, 0.0);
+ glVertex3f(x2+i, center_y+i - h, 0.0);
+ }
glEnd();
glBegin(GL_LINES);
- glVertex3f(center_x - CENTER_W / 2 - 1, -h + center_y - 1, 0.0);
- glVertex3f(center_x + CENTER_W / 2 - 1, -h + center_y - 1, 0.0);
+ glColor4f(rwt, gwt, bwt, 1.0);
+ for( int i=0; i<lw; ++i ) {
+ glVertex3f(center_x-i, y1-i - h, 0.0);
+ glVertex3f(center_x-i, y2-i - h, 0.0);
+ }
+ glColor4f(rbk, gbk, bbk, 1.0);
+ for( int i=1; i<=lw; ++i ) {
+ glVertex3f(center_x+i, y1+i - h, 0.0);
+ glVertex3f(center_x+i, y2+i - h, 0.0);
+ }
glEnd();
}
#endif