Re: [Fxruby-users] New FXRuby developer needing some direction...
Status: Inactive
Brought to you by:
lyle
From: Lyle J. <jl...@cf...> - 2003-08-13 21:11:04
|
Marc Cartright wrote: > I'm trying to use FXRuby to create a graphical image markup tool, > and being new to Fox and FXRuby, I'm having some trouble getting FXRuby to play > nicely. I'm trying to make a program to open a TIFF image, draw it on a > FXCanvas as a sort of background, and allow for "highlighting" of parts of the > image (basically translucent rectangles on certain locations of the image). OK. > Here are the major roadblocks I'm currently having: > > - The rectangles I draw seem to ignore any alpha setting I set on > a FXColor. I use FXRGBA, and no matter what I set the alpha to, > the rectangles are completely opaque. Does alpha not work > in the Fox library, or am I missing something? I think for what you are trying to accomplish, you need to change the "blit" mode used for drawing those rectangles over the existing image. You can do this using the setFunction() method for the FXDC, i.e. dc = FXDCWindow.new(theCanvas) dc.setFunction(BLT_SRC_XOR_DST) dc.fillRect(...) The constants representing the different blit modes, and their logical meaning, are shown here: http://www.fxruby.org/doc/api/classes/Fox/FXDC.html Unfortunately, I am not knowledgeable enough about this to know for sure which one is the one you're looking for. The default, BLT_SRC, does what you've already described: copy everything from the "source" to the "destination", and don't keep any of the bits from the destination bitmap. Obviously, that's not the right choice ;) If your experimentation with a few different blit modes doesn't pan out, I would recommend re-posting the question to the foxgui-users mailing list (where you will probably get a more knowledgeable response). [This is of course not an FXRuby-specific problem.] > - I want to place the FXCanvas in a FXScrollWindow, and get it to > scroll over the image. It more or less works when I load an > image, but if I resize the main window it just crops the > image to the window size, and that's it. I can't get the whole > image to display again in the scroll window. How can I get the > FXCanvas size to stay static even if I resize the FXMainWindow/ > FXScrollWindow? The FXCanvas isn't persistent, i.e. it doesn't "remember" its contents. It relies on its message target to do all of the drawing. Without actually seeing your code, I would guess that whenever a new part of the canvas scrolls into or out of view in the scroll window, the canvas is firing off SEL_PAINT messages -- but no one is handling those messages. For an example of what I'm talking about, look at the scribble.rb program that comes with FXRuby. You can scribble down a nice little sketch, but if you resize the window or do something to "trash" the picture, it will be lost. Think "Etch-A-Sketch" ;) Since scribble.rb doesn't actually record the various strokes you made to create the drawing. > - I would also like to set a "zoom level" on the image, so that by > setting the level, the image would get rescaled (along with > the rectangles that have been drawn up to that point). I got the > math worked out, but using either FXImage::scale or > FXDrawable::resize, the canvas just goes black on the resize. Anyone > know why it would be doing that? The resize() method resizes the client-side pixel buffer used by the drawable object (in this case, an FXImage instance) but doesn't otherwise do anything interesting. The scale() method should be closer to what you're looking for: it not only resizes the buffer, but then "stretches" or "shrinks" the current image to fit the new width and height. I am not 100% sure that FXImage#scale will give you the result that you're going for, but in the worst case I wouldn't expect to get a "black" image on the other side. If there's any code you can send to reproduce the (potential) bug, I'd be glad to take a look. Hope this helps, Lyle |