Glk extension proposal: images in buffer windows

Coming back to this, since the problem has come up again. How about this?

The upper 16 bits of val2 indicates what to do with the width. The lower 16 bits of val2 indicates what to do with the height. Possible values are:

  • imagescale_[XY]_Absolute ($0000): If a scale parameter is provided, interpret it as an absolute size in pixels (the current behavior). If a scale parameter is not provided, use the full, original dimensions of the image (currently undefined behavior).
  • imagescale_[XY]_Relative ($0001): If a scale parameter is provided, interpret it as a maximum fraction of the size of the current window. If not, use the full current size of the image. The image will be scaled down, preserving the aspect ratio, so that this maximum is not exceeded.
  • imagescale_[XY]_Proportional ($0002): If a scale parameter is provided, interpret it as a fraction of what this dimension would be in order to preserve the current aspect ratio (that is, a fraction of 1 for the height means “calculate the width, then use the height that will preserve the original aspect ratio”; a fraction of 1/2 means “calculate the width, then use the height that will halve the original aspect ratio”). If not, treat it as 1 (that is, preserving the original aspect ratio). If both width and height are proportional, the result is undefined behavior.

“Not provided” means that glk_image_draw was used (not providing a scale parameter for either dimension), or glk_image_draw_scaled was used, and the relevant parameter was set to 0. An image with zero size doesn’t seem useful.