This is an automatic mail response.
Please note that "fltk.bugs" is for the automated bug-tracking
system and not for direct posting as such. If you want to report this
as a bug, open a Software Trouble Report (STR) by using the Submit Bug
link at http://www.fltk.org/str.php
Few real people watch fltk.bugs, and even fewer will reply, so you
might get a better response if you post somewhere more accessible:
- if you want to discuss how to do things in FLTK in your own projects,
please post to fltk.general
- if you want to discuss issues around FLTK's own code and development
please post to fltk.development
On 13.03.2010, at 19:44, rainbowsally wrote:
> It seems best NOT to put the alpha rendering routine in the main draw_image
> loop after all. It can mess up some stuff like fluid. At least it does
> right now.
>
> So as a C = A + B function it's more predictable and still very useful,
> though this test is a bit funky.
>
> <scrnsht.png>
>
>
>
> As you can see in [A] the bottom line and especially the leftmost pixel is
> 'add'ing to the color of the background.
>
> This is built on top of an ordinary button, it's just the 'image' data
> created by
>
> 1. o->hide() on the original button to get a shot of the background with
> fl_read_image()
> then
>
> 2. o->image() using a png image imported from SVG.
>
> Here's the latest alpha adder, such as it is.
>
> --------->
>
> typedef struct
> {
> uint x, y, w, h, size;
> }WIDGET_RECT;
>
> void get_rect(WIDGET_RECT* a, Fl_Widget* o)
> {
> a->x = o->x();
> a->y = o->y();
> a->w = o->w();
> a->h = o->h();
> a->size = a->w * a->h;
> }
>
> void get_rect(WIDGET_RECT* a, Fl_RGB_Image* o)
> {
> a->x = 0;
> a->y = 0;
> a->w = o->w();
> a->h = o->h();
> a->size = a->w * a->h;
> }
>
>
> Fl_RGB_Image* get_screen_image(Fl_Widget* o, uchar alpha)
> {
> WIDGET_RECT r;
> get_rect(&r, o);
> uchar* array = fl_read_image(0, r.x, r.y, r.w, r.h, alpha);
> Fl_RGB_Image* tmp = new Fl_RGB_Image(array, r.w, r.h, 4);
> return tmp;
> }
>
> typedef union
> {
> struct
> {
> uchar red;
> uchar green;
> uchar blue;
> uchar alpha;
> }byte;
> void* cref;
> }PIXELS;
>
> #include <string.h>
> Fl_RGB_Image* add_alpha_images(Fl_RGB_Image* image_1, Fl_RGB_Image* image_2,
> int x_where, int y_where)
> {
> WIDGET_RECT r;
> get_rect(&r, image_1);
>
> Fl_RGB_Image* tmp = image_1;
> Fl_RGB_Image* fg = image_2;
> uchar* array = (uchar*)malloc(r.size * 4);
> memcpy(array, image_1->array, r.size * 4);
>
> Fl_RGB_Image* bg = new Fl_RGB_Image(array, r.w, r.h, 4);
> bg->alloc_array = 1;
>
> int X = x_where; int Y = y_where; int W = fg->w(); int H = fg->h();
> int bgW = bg->w(); int bgH = bg->h();
>
> // clip
> if((W + y_where) > bg->w())
> W = bg->w() - y_where;
>
> if((H + x_where) > bg->h())
> H = bg->h() - y_where;
> //...
>
> if((W <= 0) || (H <= 0))
> return 0;
>
> PIXELS acc;
> PIXELS* src = (PIXELS*)fg->array;
> PIXELS* pdest = (PIXELS*)bg->array + X + (Y * bgW);
> PIXELS* dest;
> PIXELS s;
> PIXELS d;
> uint alpha, beta;
>
> for(int y = 0; y < H; y++)
> {
> dest = pdest;
> for(int x = 0; x < W; x++)
> {
> alpha = src->byte.alpha + 1;
> beta = 260 - alpha;
> s = *src;
> d = *dest;
> acc.byte.red = (((s.byte.red*alpha) + (d.byte.red*beta)) >> 8);
> acc.byte.blue = (((s.byte.blue*alpha) + (d.byte.blue*beta)) >> 8);
> acc.byte.green = (((s.byte.green*alpha) + (d.byte.green*beta)) >> 8);
> acc.byte.alpha = 255; // or master alpha?
> *dest = acc;
> src++;
> dest++;
> }
> pdest += bgW;
> }
> return bg;
> }
>
> <---------
>
> The code is probably a mess. I'm just still trying to wrap my brain around
> C/C++. I'm a Forth fan and it's just soooOOoooo... different. :-) Not sure
> I'm releasing memory where I should and I'm not sure how these C++ objects
> delete themselves or when they do it.
>
> Still having lots of fun.. losing hair and cussing like wild sometimes, but
> it's coming along. :-)
>
>
> _______________________________________________
> fltk-bugs mailing list
> [email protected]
> http://lists.easysw.com/mailman/listinfo/fltk-bugs
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs