# FXRuby dynamic drawing canvas and off-screen image buffer resize

**URL:** <https://www.ruby-forum.com/t/fxruby-dynamic-drawing-canvas-and-off-screen-image-buffer-resize/128482>\
**Category:** Ruby\
**Created:** [February 8, 2008, 12:32am UTC](https://www.ruby-forum.com/t/fxruby-dynamic-drawing-canvas-and-off-screen-image-buffer-resize/128482 "2008-02-08T00:32:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ranieri\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/43a26b/32.png) [@Ranieri\_T](https://www.ruby-forum.com/u/Ranieri_T)\
**Post date:** [February 8, 2008, 12:32am UTC](https://www.ruby-forum.com/t/fxruby-dynamic-drawing-canvas-and-off-screen-image-buffer-resize/128482/1 "2008-02-08T00:32:25Z")

</div>

How can I use the drawing canvas and its off-screen image buffer, say  
FXImage, to dynamically resize or have its width and height attributes  
changed in reply to user interaction with the main window  
(FXMainWindow)?

It seems that whem I put initial values to W and H of the canvas or  
FXImage,  
they remain with its initial values no matter what I do whem resizing  
the  
main window.

I have to reset its values for each resize, but how?

---

<div class="post-metadata">

**Author:** ![Ranieri\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/43a26b/32.png) [@Ranieri\_T](https://www.ruby-forum.com/u/Ranieri_T)\
**Post date:** [February 8, 2008, 4:32pm UTC](https://www.ruby-forum.com/t/fxruby-dynamic-drawing-canvas-and-off-screen-image-buffer-resize/128482/2 "2008-02-08T16:32:27Z")

</div>

On Feb 7, 2008, at 5:31 PM, Ranieri T. wrote:

> I have to reset its values for each resize, but how?

If you want the image to be the same size as the canvas that you’re  
drawing it into, you need to call resize() on the image whenever the  
canvas size changes.

---

<div class="post-metadata">

**Author:** ![Ranieri\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/43a26b/32.png) [@Ranieri\_T](https://www.ruby-forum.com/u/Ranieri_T)\
**Post date:** [February 9, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/fxruby-dynamic-drawing-canvas-and-off-screen-image-buffer-resize/128482/3 "2008-02-09T14:43:18Z")

</div>

Thanks, Lyle  
A class to resize(w, h) on image works fine.  
I’m very happy with your help.
