How do I get the dimensions of an image in Inform?

The Glk function I want is glui32 glk_image_get_info(glui32 image, glui32 *width, glui32 *height). But I’m unsure how the “passing pointers in as parameters” thing works in Inform. How can I get the width and height of an image in I6 (or specifically from the subset of I6 used in I7)?

You can use gg_arguments as a pointer, though you have to pass in the two addresses manually. Otherwise you could use any variable or global.

To decide what number is the height of (image - figure name):
	(- GetImageSize(ResourceIDsOfFigures-->{image}, 1) -).

To decide what number is the width of (image - figure name):
	(- GetImageSize(ResourceIDsOfFigures-->{image}, 0) -).

Include (-
[ GetImageSize image index;
	glk_image_get_info(image, gg_arguments, gg_arguments + WORDSIZE);
	return gg_arguments-->index;
];
-).
1 Like