Re: [Fxruby-users] hard time using images
Status: Inactive
Brought to you by:
lyle
From: Jeroen v. d. Z. <je...@fo...> - 2004-07-07 14:37:22
|
On Wednesday 07 July 2004 10:08 am, Andre' Wagner wrote: > Hello folks, > > I think I'm failing to understand how do I manipulate a image widget > in my application. I putted the FXImage in my app - and it appears ok > - but if I try to setPixel in it then I get a segfault. > > I peeked into the examples, and I see they use a FXDCWindow and a > FXCanvas, but I can't understand it very well. I looked into the > tutorial and the docs but I haven't found anything that cleared my > mind. > > Is there a image tutorial for FXRuby or something like that on the > net? Or might someone give me a few pointers here? > > Thank you in advance, > > Andr=E9 The think to keep in mind is that there's two sides to FXImage: the array of pixels which is kept in your program and the device-specific bitmap which is kept in the display server. Now, to keep memory down, by default FXImage ditches the pixel array in the program, since USING the image in drawing operations normally requires only the bitmap in the display server. Of course, sometimes you need the local pixel array, and there's a way to hang on to that, by passing the IMAGE_KEEP option. Also, there is a way to regenerate the server-side bitmap from the local pixel array, which you can do by calling render(). Finally, since you can use drawing commands to draw things into the bitmap that is kept in the server, you can read back the bitmap into the local image pixel array by calling restore(). The API setPixel() works on the local image pixel array, and you must make sure that the pixel array is kept around for that to work properly. Note also that the local pixel array is only deleted after the server-side bitmap has been populated, which means basically that prior to create() you still have full access to the local pixel array. Hope this helps, - Jeroen |