I was hoping somebody familiar with Flexible Windows extension can show me how to make an image display in a bottom window. Using this code, the bottom window opens, but I can’t get it to display any image?
I tried to adapt the only example I could find of making an image display, but so far with no luck…
Thanks for any help in figuring this out!
[code]Include Flexible Windows by Jon Ingold.
Figure 10 is the file “pic10.jpg”.
The Study is a room. In the study is an old oak desk. On the desk is a Parker pen, a letter, an envelope and twenty dollars.
The Study is north of the Library.
The Library is a room.
The Library is south of the Study.
The bottom-window is a graphics g-window spawned by the main-window. The position of the bottom-window is g-placebelow.
The bottom-window has back-colour g-black.
The measurement of the bottom-window is 30.
When play begins:
open up the bottom-window.
The current image is a figure-name that varies.
To depict (f - a figure-name):
change the current image to f;
follow the window-drawing rules for the bottom-window.
Window-drawing rule for the bottom-window (this is the construct inventory rule):
move focus to bottom-window, clearing the window;
depict Figure 10;
return to main screen.
Window-drawing rule for the bottom-window (this is the draw scaled image rule):
if bottom-window is g-unpresent, rule fails;
clear the bottom-window;
draw scaled copy of current image in bottom-window.
To draw scaled copy of (f - a figure-name) in (g - a g-window):
(- DrawScaled({f}, {g}); -).
Include (-
! Doing scaling calculations in I6 lets us handle bigger numbers
[ GetImageSize curimg index result;
result = glk_image_get_info( ResourceIDsOfFigures-->curimg, gg_arguments, gg_arguments+WORDSIZE);
return gg_arguments-->index;
];
[ DrawScaled figure g w_total h_total graph_height graph_width w_offset h_offset;
graph_height = WindowSize(g, 1);
graph_width = gg_arguments-->0;
w_total = GetImageSize(figure, 0);
h_total = gg_arguments-->1;
if (graph_height - h_total < 0) ! if the image won't fit, find the scaling factor
{
w_total = (graph_height * w_total)/h_total;
h_total = graph_height;
}
if (graph_width - w_total < 0)
{
h_total = (graph_width * h_total)/w_total;
w_total = graph_width;
}
w_offset = (graph_width - w_total)/2; if (w_offset < 0) w_offset = 0;
h_offset = (graph_height - h_total)/2; if (h_offset < 0) h_offset = 0;
glk_image_draw_scaled(g.ref_number, ResourceIDsOfFigures-->figure, w_offset, h_offset, w_total, h_total);
];
-).
[/code]