{
public:
static void png_read_function(png_structp png_ptr,
- png_bytep data, png_size_t length)
+ png_bytep data, png_size_t length)
{
VFrame *frame = (VFrame*)png_get_io_ptr(png_ptr);
if(frame->image_size - frame->image_offset < (long)length)
void VFrame::get_temp(VFrame *&vfrm, int w, int h, int color_model)
{
- if( vfrm && ( vfrm->get_w() != w || vfrm->get_h() != h ) ) {
- delete vfrm; vfrm = 0;
- }
- if( !vfrm ) vfrm = new VFrame(w, h, color_model, 0);
+ if( vfrm && ( vfrm->get_w() != w || vfrm->get_h() != h ) ) {
+ delete vfrm; vfrm = 0;
+ }
+ if( !vfrm ) vfrm = new VFrame(w, h, color_model, 0);
}
int ww = w * xscale, hh = h * yscale;
if( ww != w || hh != h ) {
VFrame vframe(*this);
- reallocate(NULL, -1, 0, 0, 0, ww, hh, color_model, -1);
+ reallocate(NULL, -1, 0, 0, 0, ww, hh, color_model, -1);
transfer_from(&vframe);
}
return 0;
// rgb component colors (eg. from colors.h)
// a (~alpha) transparency, 0x00==solid .. 0xff==transparent
-void VFrame::set_pixel_color(int argb)
+void VFrame::set_pixel_color(int rgb, int a)
{
- pixel_rgb = argb;
- int ia = 0xff & (pixel_rgb >> 24);
+ pixel_rgb = (rgb&0xffffff) | ~a<<24;
int ir = 0xff & (pixel_rgb >> 16);
int ig = 0xff & (pixel_rgb >> 8);
int ib = 0xff & (pixel_rgb >> 0);
YUV::yuv.rgb_to_yuv_8(ir, ig, ib);
- pixel_yuv = (ia<<24) | (ir<<16) | (ig<<8) | (ib<<0);
+ pixel_yuv = (a<<24) | (ir<<16) | (ig<<8) | (ib<<0);
}
void VFrame::set_stiple(int mask)
case BC_A8:
DRAW_PIXEL(uint8_t, ib, 0, 0, 1, 0);
break;
+ case BC_RGB888:
case BC_YUV888:
DRAW_PIXEL(uint8_t, ir, ig, ib, 3, 0);
break;
virtual int draw_pixel(int x, int y);
int pixel_rgb, pixel_yuv, stipple;
- void set_pixel_color(int rgb);
- void set_pixel_color(int rgb, int a) { set_pixel_color((rgb&0xffffff)|((~a&0xff)<<24)); }
+ void set_pixel_color(int rgb, int a=0xff);
void set_stiple(int mask);
void draw_line(int x1, int y1, int x2, int y2);
void draw_smooth(int x1, int y1, int x2, int y2, int x3, int y3);
void Sketcher::draw_point(VFrame *vfrm, SketcherPoint *pt, int color, int d)
{
int r = d/2+1, x = pt->x, y = pt->y;
- vfrm->set_pixel_color(color, 0xff);
+ vfrm->set_pixel_color(color);
vfrm->draw_smooth(x-r,y+0, x-r, y-r, x+0,y-r);
vfrm->draw_smooth(x+0,y-r, x+r, y-r, x+r,y+0);
vfrm->draw_smooth(x+r,y+0, x+r, y+r, x+0,y+r);
int m = cv->points.size();
if( !m || cv->pen == PTY_OFF ) continue;
img->clear_frame();
- img->set_pixel_color(cv->color);
+ img->set_pixel_color(cv->color, (~cv->color>>24)&0xff);
cv->draw(img);
overlay_frame->overlay(out, img, 0,0,w,h, 0,0,w,h,
1.f, TRANSFER_NORMAL, NEAREST_NEIGHBOR);