[Bf-committers] UV/Image Editor's zoom calculation

Masahito Takahashi mato1492 at gmail.com
Tue Jan 26 12:30:21 CET 2010


I submitted a patch, which is related to UV/Image Editor's zoom calculation.

[#20800] UV/Image Editor's Zoom rate is not properly calculated.

Currently UV/Image Editor's image is displayed a little smaller than
it should be.
I think it is because zoomx, zoomy value is not calculated properly.

Zoomx and zoomy is calculated in ED_space_image_zoom() like this way.
*zoomx= (float)(ar->winrct.xmax -
ar->winrct.xmin)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width);
*zoomy= (float)(ar->winrct.ymax -
ar->winrct.ymin)/(float)((ar->v2d.cur.ymax -

And ar->winrct.xmax and ar->winrct.ymax is calculated in
image_main_area_set_view2d() like this way.
ar->v2d.cur.xmax= ar->v2d.cur.xmin + ((float)winx/sima->zoom);
ar->v2d.cur.ymax= ar->v2d.cur.ymin + ((float)winy/sima->zoom);

Winx and winy is calculated like this way.
winx= ar->winrct.xmax - ar->winrct.xmin + 1;
winy= ar->winrct.ymax - ar->winrct.ymin + 1;

So I think calculation of zoomx, zoomy needs "+ 1" like this.
*zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin +
1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width);
*zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin +
1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height);

I sent a mail about this patch once, but seems to failed to receive.
So send this again with different mail title.
If I send same mail twice, then I am sorry that I bother you.

Thank you.

Masahito Takahashi.

More information about the Bf-committers mailing list