void framedraw_redraw(lives_special_framedraw_rect_t *framedraw, boolean reload, LiVESPixbuf *pixbuf) { // this will draw the mask (framedraw_bitmap) and optionally reload the image // and then combine them int fd_height; int fd_width; int width,height; double xstartf,ystartf,xendf,yendf; lives_painter_t *cr; if (mainw->current_file<1||cfile==NULL) return; if (framedraw->rfx->source_type==LIVES_RFX_SOURCE_RFX) if (noupdate) return; fd_width=lives_widget_get_allocation_width(mainw->framedraw); fd_height=lives_widget_get_allocation_height(mainw->framedraw); width=cfile->hsize; height=cfile->vsize; calc_maxspect(fd_width,fd_height,&width,&height); // copy from orig, resize // copy orig layer to layer if (mainw->fd_layer!=NULL) { weed_layer_free(mainw->fd_layer); mainw->fd_layer=NULL; } if (reload||mainw->fd_layer_orig==NULL) load_framedraw_image(pixbuf); mainw->fd_layer=weed_layer_copy(NULL,mainw->fd_layer_orig); // resize to correct size resize_layer(mainw->fd_layer, width, height, LIVES_INTERP_BEST, WEED_PALETTE_END, 0); cr=layer_to_lives_painter(mainw->fd_layer); // draw on the lives_painter // her we dont offset because we are drawing in the pixbuf, not the widget switch (framedraw->type) { case LIVES_PARAM_SPECIAL_TYPE_RECT_MULTRECT: // deprecated // scale values if (framedraw->xstart_param->dp==0) { xstartf=(double)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->xstart_param->widgets[0])); xstartf=xstartf/(double)cfile->hsize*(double)width; } else { xstartf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->xstart_param->widgets[0])); xstartf=xstartf*(double)width; } if (framedraw->xend_param->dp==0) { xendf=(double)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->xend_param->widgets[0])); xendf=xendf/(double)cfile->hsize*(double)width; } else { xendf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->xend_param->widgets[0])); xendf=xendf*(double)width; } if (framedraw->ystart_param->dp==0) { ystartf=(double)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->ystart_param->widgets[0])); ystartf=ystartf/(double)cfile->vsize*(double)height; } else { ystartf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->ystart_param->widgets[0])); ystartf=ystartf*(double)height; } if (framedraw->yend_param->dp==0) { yendf=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->yend_param->widgets[0])); yendf=yendf/(double)cfile->vsize*(double)height; } else { yendf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->yend_param->widgets[0])); yendf=yendf*(double)height; } lives_painter_set_source_rgb(cr, 1., 0., 0.); lives_painter_rectangle(cr,xstartf-1.,ystartf-1.,xendf+2.,yendf+2.); lives_painter_stroke(cr); break; case LIVES_PARAM_SPECIAL_TYPE_RECT_MULTIRECT: case LIVES_PARAM_SPECIAL_TYPE_RECT_DEMASK: if (framedraw->xstart_param->dp==0) { xstartf=(double)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->xstart_param->widgets[0])); xstartf=xstartf/(double)cfile->hsize*(double)width; } else { xstartf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->xstart_param->widgets[0])); xstartf=xstartf*(double)width; } if (framedraw->xend_param->dp==0) { xendf=(double)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->xend_param->widgets[0])); xendf=xendf/(double)cfile->hsize*(double)width; } else { xendf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->xend_param->widgets[0])); xendf=xendf*(double)width; } if (framedraw->ystart_param->dp==0) { ystartf=(double)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->ystart_param->widgets[0])); ystartf=ystartf/(double)cfile->vsize*(double)height; } else { ystartf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->ystart_param->widgets[0])); ystartf=ystartf*(double)height; } if (framedraw->yend_param->dp==0) { yendf=(double)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->yend_param->widgets[0])); yendf=yendf/(double)cfile->vsize*(double)height; } else { yendf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->yend_param->widgets[0])); yendf=yendf*(double)height; } if (b1_held||framedraw->type==LIVES_PARAM_SPECIAL_TYPE_RECT_MULTIRECT) { lives_painter_set_source_rgb(cr, 1., 0., 0.); lives_painter_rectangle(cr,xstartf-1.,ystartf-1.,xendf-xstartf+2.,yendf-ystartf+2.); lives_painter_stroke(cr); } else { if (!b1_held) { // create a mask which is only opaque within the clipping area lives_painter_rectangle(cr,0,0,width,height); lives_painter_rectangle(cr,xstartf,ystartf,xendf-xstartf+1.,yendf-ystartf+1.); lives_painter_set_operator(cr, LIVES_PAINTER_OPERATOR_DEST_OUT); lives_painter_set_source_rgba(cr, .0, .0, .0, .5); lives_painter_set_fill_rule(cr, LIVES_PAINTER_FILL_RULE_EVEN_ODD); lives_painter_fill(cr); } } break; case LIVES_PARAM_SPECIAL_TYPE_SINGLEPOINT: if (framedraw->xstart_param->dp==0) { xstartf=(double)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->xstart_param->widgets[0])); xstartf=xstartf/(double)cfile->hsize*(double)width; } else { xstartf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->xstart_param->widgets[0])); xstartf=xstartf*(double)width; } if (framedraw->ystart_param->dp==0) { ystartf=(double)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(framedraw->ystart_param->widgets[0])); ystartf=ystartf/(double)cfile->vsize*(double)height; } else { ystartf=lives_spin_button_get_value(LIVES_SPIN_BUTTON(framedraw->ystart_param->widgets[0])); ystartf=ystartf*(double)height; } lives_painter_set_source_rgb(cr, 1., 0., 0.); lives_painter_move_to(cr,xstartf,ystartf-3); lives_painter_line_to(cr,xstartf,ystartf+3); lives_painter_stroke(cr); lives_painter_move_to(cr,xstartf-3,ystartf); lives_painter_line_to(cr,xstartf+3,ystartf); lives_painter_stroke(cr); break; default: break; } lives_painter_to_layer(cr, mainw->fd_layer); lives_painter_destroy(cr); redraw_framedraw_image(); }
void on_live_tvcard_activate(LiVESMenuItem *menuitem, livespointer user_data) { int cardno=0; int new_file=mainw->first_free_file; int response; char *com,*tmp; char *fifofile=lives_strdup_printf("%s/tvpic.%d",prefs->tmpdir,capable->mainpid); char *chanstr; char *devstr; char *fname; LiVESWidget *card_dialog; lives_tvcardw_t *tvcardw; mainw->open_deint=FALSE; card_dialog=create_cdtrack_dialog(4,NULL); tvcardw=(lives_tvcardw_t *)lives_widget_object_get_data(LIVES_WIDGET_OBJECT(card_dialog),"tvcard_data"); response=lives_dialog_run(LIVES_DIALOG(card_dialog)); if (response==LIVES_RESPONSE_CANCEL) { lives_widget_destroy(card_dialog); lives_free(fifofile); lives_free(tvcardw); return; } cardno=(int)mainw->fx1_val; chanstr=lives_strdup_printf("%d",(int)mainw->fx2_val); if (lives_list_find(mainw->videodevs,LIVES_INT_TO_POINTER(cardno))) { lives_widget_destroy(card_dialog); do_card_in_use_error(); lives_free(chanstr); lives_free(fifofile); lives_free(tvcardw); return; } fname=lives_strdup_printf(_("TV card %d"),cardno); if (!get_new_handle(new_file,fname)) { lives_widget_destroy(card_dialog); lives_free(chanstr); lives_free(fifofile); lives_free(fname); lives_free(tvcardw); return; } devstr=lives_strdup_printf("/dev/video%d",cardno); if (!check_dev_busy(devstr)) { lives_widget_destroy(card_dialog); do_dev_busy_error(fname); lives_free(devstr); lives_free(chanstr); lives_free(fifofile); lives_free(fname); lives_free(tvcardw); return; } mainw->videodevs=lives_list_append(mainw->videodevs,LIVES_INT_TO_POINTER(cardno)); mainw->current_file=new_file; cfile->deinterlace=mainw->open_deint; unlink(fifofile); mkfifo(fifofile,S_IRUSR|S_IWUSR); if (!tvcardw->use_advanced) { com=lives_strdup_printf("%s open_tv_card \"%s\" \"%s\" \"%s\" \"%s\"",prefs->backend,cfile->handle,chanstr, devstr,fifofile); } else { double fps=0.; char *driver=NULL,*outfmt=NULL; int width=0,height=0; int input=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(tvcardw->spinbuttoni)); if (!lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(tvcardw->radiobuttond))) { width=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(tvcardw->spinbuttonw)); height=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(tvcardw->spinbuttonh)); fps=lives_spin_button_get_value(LIVES_SPIN_BUTTON(tvcardw->spinbuttonf)); } driver=lives_combo_get_active_text(LIVES_COMBO(tvcardw->combod)); outfmt=lives_combo_get_active_text(LIVES_COMBO(tvcardw->comboo)); com=lives_strdup_printf("%s open_tv_card \"%s\" \"%s\" \"%s\" \"%s\" %d %d %d %.3f \"%s\" \"%s\"", prefs->backend,cfile->handle,chanstr, devstr,fifofile,input,width,height,fps,driver,outfmt); lives_free(driver); lives_free(outfmt); } lives_widget_destroy(card_dialog); lives_free(tvcardw); mainw->com_failed=FALSE; lives_system(com,FALSE); lives_free(com); if (mainw->com_failed) { mainw->com_failed=FALSE; lives_free(fname); lives_free(chanstr); lives_free(fifofile); lives_free(devstr); return; } if (!open_yuv4m_inner(fifofile,fname,new_file,YUV4_TYPE_TV,cardno)) { lives_free(fname); lives_free(chanstr); lives_free(fifofile); lives_free(devstr); return; } lives_snprintf(cfile->type,40,"%s",fname); d_print((tmp=lives_strdup_printf(_("Opened TV card %d (%s)"),cardno,devstr))); lives_free(tmp); lives_free(fname); lives_free(chanstr); lives_free(devstr); lives_free(fifofile); }