Haven't tested it; but I think the following change is needed:
change
int y = y_pixel * vid_get_viewport_width();
to
int y = y_pixel * vid_get_viewport_byte_width() * vid_get_viewport_yscale();
Working on "object recognition"script and I'm now getting strange crashes in the keyboard task that appear to be from calculating the offset into the display buffer so I'll try that. Thanks
Update 1 : that didn't fix it - something else must be wrong ... back to debugging 101
Update 2 : seems to
really not like this line (crashes with it in - works with it commented out)
img += vid_get_viewport_image_offset(); // offset into viewport for when image size != viewport size (e.g. 16:9 image on 4:3 LCD)
Same line is in the standard MD code - but I'm hammering it thousands of times looking at each pixel and it doesn't always crash right way.
Update 3 : found the crash source - bad implementation of the vid_get_viewport_xxx() functions in lib.c for the A1200. Looks like shooting_get_prop(PROPCASE_ASPECT_RATIO) returns a value greater than 3 at times?