Re: Drawing antialiased shapes with alpha transparency



On Sat, 8 Jan 2005, Samuel Abels wrote:

I also tried using

 Gdk::Window::draw_rgb_32_image(gc,
                                x, y, width, height,
                                Gdk::RGB_DITHER_NONE,
                                buffer,
                                stride);

but this API does not allow to copy only an area (x1, y1, x2, y2) of the
source buffer to the widget's buffer (x3, y3), so I would have to create
another temporary image. If I don't, this is very slow (there is a
flicker).

well, with a clever rowstride you can solve this. let's say orig_buffer is sized w x h, and each pixel takes up 4 bytes. You want to render (x, y, view_w, view_h). So you can do

new_buffer = orig_buffer + (y * orig_rowstride) + (x * 4);
win.draw_rgb_image (gc, x, y, view_w, view_h, Gdk::RGB_DITHER_NONE,
		    new_buffer, orig_rowstride);

(I don't have the faintest idea what you're actually doing (never looked at Cairo), just pointing out how you can avoid copying the buffer to render sub-regions of it)

--
   .--= ULLA! =---------------------.   `We are not here to give users what
   \     http://cactus.rulez.org     \   they want'  -- RMS, at GUADEC 2001
    `---= cactus cactus rulez org =---'
<NyseriA> Things I've learned about war from videogames: If you find yourself mortally wounded by an enemy sniper be sure to let him know that he is a faggot.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]