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);
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<h; ++i ) fwrite(rows[i],3,w,fp);
+ fclose(fp);
+ if( frm != vfrm ) delete frm;
+}
+
#define ZERO_YUV(components, type, max) \
{ \
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);
int ig = 0xff & (pixel_rgb >> 8);
int ib = 0xff & (pixel_rgb >> 0);
YUV::yuv.rgb_to_yuv_8(ir, ig, ib);
- pixel_yuv = (a<<24) | (ir<<16) | (ig<<8) | (ib<<0);
+ pixel_yuv = (~a<<24) | (ir<<16) | (ig<<8) | (ib<<0);
}
void VFrame::set_stiple(int mask)