X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fvframe.C;h=4960ff26834951df49a502ecb9532b506e10c61d;hp=5cd9901b3666e38eb813ac4c0d1f92da3060a741;hb=8fd64d1d3770c95e2a7cba1049e909cadb4e1fbf;hpb=ad498171bc20d8187dfa891da26d7b32a2ff0380 diff --git a/cinelerra-5.1/guicast/vframe.C b/cinelerra-5.1/guicast/vframe.C index 5cd9901b..4960ff26 100644 --- a/cinelerra-5.1/guicast/vframe.C +++ b/cinelerra-5.1/guicast/vframe.C @@ -282,6 +282,8 @@ int VFrame::reset_parameters(int do_opengl) pixel_rgb = 0x000000; // BLACK pixel_yuv = 0x008080; stipple = 0; + clear_color = 0x000000; + clear_alpha = 0x00; if(do_opengl) { @@ -390,7 +392,8 @@ int VFrame::get_keyframe() void VFrame::get_temp(VFrame *&vfrm, int w, int h, int color_model) { - if( vfrm && ( vfrm->get_w() != w || vfrm->get_h() != h ) ) { + if( vfrm && ( vfrm->color_model != color_model || + vfrm->get_w() != w || vfrm->get_h() != h ) ) { delete vfrm; vfrm = 0; } if( !vfrm ) vfrm = new VFrame(w, h, color_model, 0); @@ -874,6 +877,28 @@ int VFrame::write_png(const char *path) return 0; } +void VFrame::write_ppm(VFrame *vfrm, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + char fn[BCTEXTLEN]; + vsnprintf(fn, sizeof(fn), fmt, ap); + va_end(ap); + FILE *fp = fopen(fn,"w"); + if( !fp ) { perror("write_ppm"); return; } + VFrame *frm = vfrm; + if( frm->get_color_model() != BC_RGB888 ) { + frm = new VFrame(frm->get_w(), frm->get_h(), BC_RGB888); + frm->transfer_from(vfrm); + } + int w = frm->get_w(), h = frm->get_h(); + fprintf(fp,"P6\n%d %d\n255\n",w,h); + unsigned char **rows = frm->get_rows(); + for( int i=0; i= 0 ) { + BC_CModels::init_color(clear_color, clear_alpha, get_rows(), get_color_model(), + get_y(), get_u(), get_v(), 0,0, get_w(),get_h(), get_bytes_per_line()); + } + else + black_frame(); } void VFrame::rotate90() @@ -1147,7 +1189,8 @@ int VFrame::transfer_from(VFrame *that, int bg_color, int in_x, int in_y, int in timestamp = that->timestamp; copy_params(that); - if( this->get_color_model() == that->get_color_model() && + if( in_x == 0 && in_y == 0 && in_w == that->get_w() && in_h == that->get_h() && + bg_color == 0 && this->get_color_model() == that->get_color_model() && this->get_w() == that->get_w() && this->get_h() == that->get_h() && this->get_bytes_per_line() == that->get_bytes_per_line() ) return this->copy_from(that);