How can I transform XY coordinates and height/width on a scaled image to an original sized image?

前端 未结 2 958
情歌与酒
情歌与酒 2020-12-14 10:32

Related Question

I am trying to do the same thing as in the linked question, but with C#. I am showing a scaled image and am allowing a user to select an area to cro

2条回答
  •  萌比男神i
    2020-12-14 11:20

    You can get the percent locations for the scaled images and turn them back into coords for the unscaled image:

    pX1 = scaledX1/scaled_width
    pY1 = scaledY1/scaled_height
    
    unscaledX1 = ceiling(unscaled_width * pX1)
    unscaledY1 = ceiling(unscaled_height * pY1)
    

提交回复
热议问题