Sketchup API获取具有给定路径的图像的宽度和高度 [英] Sketchup API Get the width and height of image with given path

查看:109
本文介绍了Sketchup API获取具有给定路径的图像的宽度和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取具有给定路径的图像的宽度和高度. 这是我的详细代码

I need to get width and height of image with given path. Here is my detail code

path  = UI.openpanel("Open Image File","/","*.jpg;*.png;*.jpeg")
if(path != nil)
  #get the original width of image
  old_width = ??????
  #get the original height of image
  old_height = ??????
  #get the orginal rate of image
  rate = old_width.to_f / old_height_to_f
  #then import image into model as a Image entity
  point = Geom::Point3d.new 0,10,0
  objImage = entities.add_image path, point , 318,318/rate
end

我需要一种通过给定路径在此代码中获取old_width和old_height值的方法. 谢谢

I need a way to get value of old_width and old_height in this code with given path. Thanks you

推荐答案

您无需指定height,它是可选的.如果仅指定width,则会根据图像的比例自动调整height.

You won't need to specify the height, it is optional. If you specify just the width the height will be adjusted automatically based on the proportions of the image.

path = UI.openpanel("Open Image File", "/", "*.jpg;*.png;*.jpeg")
if !path.nil?
  point = Geom::Point3d.new(0, 10, 0)
  image = entities.add_image(path, point, 318)
end

这篇关于Sketchup API获取具有给定路径的图像的宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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