数学将图像置于屏幕中心? [英] math to center an image on a screen?

查看:119
本文介绍了数学将图像置于屏幕中心?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定尺寸(w,h)和尺寸照片(ww,hh)的屏幕,如何计算屏幕上的x,y点以放置图像的左上角,使图像居中?

Given a screen of dimensions (w,h) and a photo of dimension (ww,hh) how do I calculate the x,y point on screen to place the upper left corner of the image so the image is centered?

谢谢!

推荐答案

x = (w/2) - (ww/2)
y = (h/2) - (hh/2)

这篇关于数学将图像置于屏幕中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆