Re: Fast Image Manipulation?



Federico Mena Quintero wrote:
> 
> >  Now, if I were drawing straight to the screen, I could keep my items image as a
> >  gdk pixmap and do a simple gdk_draw_pixmap to blast the appropriate section.
> >
> >  If I use gdk_imlib_paste_image, I don't get to choose a section, it just scales
> >  the image to fit. I'd have to do a gdk_imlib_crop_and_clone_image first, which
> >  is too slow (I assume). Or, I'd have to do that at the beginning, and keep many
> >  smaller item images, which takes up more memory (I assume). That's not good
> >  because I may have many item types and frames.
> 
> You need to do the following.
> 
> When your game starts up, load all the images using gdk_imlib.  Render
> them with gdk_imlib_render(), and extract the pixmaps/masks with
> gdk_imlib_move_image() and gdk_imlib_move_mask(), respectively.  Keep
> those pixmaps around.
> 
> When you need to paint a frame, clear your off-screen pixmap, and then
> fill it using gdk_draw_pixmap() from the pixmaps you created when the
> game started up.  Then blast the off-screen pixmap to your drawing
> area.
> 
>   Federico

Awesome. I had all the steps, just didn't see how to get the individual
image/pixmap onto the offscreen pixmap before blasting it to the screen. I now
see that gdk_draw_pixmap works from pixmap to pixmap.

Hopefully tomorrow evening I can ramp up the numbers and see if performance is
an issue.

-- 
SEGV    http://www.cgocable.net/~mlepage/



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