From: Good Guy Date: Tue, 20 Nov 2018 02:51:09 +0000 (-0700) Subject: add rgb to draw_pixel (missed that one), bclistbox btn1 select tweak, set_pixel_color... X-Git-Tag: 2019-08~181 X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=commitdiff_plain;h=3b2c7c9370c55deb546f76895d6829fbc9476a18;ds=sidebyside add rgb to draw_pixel (missed that one), bclistbox btn1 select tweak, set_pixel_color api tweak --- diff --git a/cinelerra-5.1/guicast/bclistbox.C b/cinelerra-5.1/guicast/bclistbox.C index 4a55593f..e99d7316 100644 --- a/cinelerra-5.1/guicast/bclistbox.C +++ b/cinelerra-5.1/guicast/bclistbox.C @@ -2646,7 +2646,7 @@ int BC_ListBox::button_press_event() } // Select single item else { - if( !current_item->selected || !new_value ) { + if( !current_item->selected || (get_buttonpress() == 1 && !new_value) ) { set_all_selected(data, 0); set_selected(data, selection_number, 1); } diff --git a/cinelerra-5.1/guicast/vframe.C b/cinelerra-5.1/guicast/vframe.C index 6f0dfbb1..82d0830c 100644 --- a/cinelerra-5.1/guicast/vframe.C +++ b/cinelerra-5.1/guicast/vframe.C @@ -44,7 +44,7 @@ class PngReadFunction { 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) @@ -390,10 +390,10 @@ 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 ) ) { - 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); } @@ -828,7 +828,7 @@ int VFramePng::read_png(const unsigned char *data, long sz, double xscale, doubl 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; @@ -1352,15 +1352,14 @@ int VFrame::get_memory_usage() // 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) @@ -1397,6 +1396,7 @@ int VFrame::draw_pixel(int x, int y) 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; diff --git a/cinelerra-5.1/guicast/vframe.h b/cinelerra-5.1/guicast/vframe.h index e6bbc236..dbf4dab0 100644 --- a/cinelerra-5.1/guicast/vframe.h +++ b/cinelerra-5.1/guicast/vframe.h @@ -346,8 +346,7 @@ public: 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); diff --git a/cinelerra-5.1/plugins/sketcher/sketcher.C b/cinelerra-5.1/plugins/sketcher/sketcher.C index 954f7a2c..a954c7ca 100644 --- a/cinelerra-5.1/plugins/sketcher/sketcher.C +++ b/cinelerra-5.1/plugins/sketcher/sketcher.C @@ -412,7 +412,7 @@ void Sketcher::update_gui() 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); @@ -727,7 +727,7 @@ int Sketcher::process_realtime(VFrame *input, VFrame *output) 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);