查看: 2848|回复: 5

[已经解决] 在xp中,如何用事件脚本获取图片素材的宽和高?

[复制链接]
梦石
0
星屑
2876
在线时间
172 小时
注册时间
2020-8-9
回帖
100
发表于 2021-7-17 20:45:18 | 显示全部楼层 |阅读模式
悬赏40星屑已解决
本帖最后由 939034448 于 2021-7-17 21:49 编辑

如题,在搜索里没找到像要的,看了一些教程,但可能因为是va的教程,没能生效
[pre lang="ruby"]$game_variables[5]=
Graphics.width-手机(极光).width[/pre]

像上面这个,“手机(极光)”是素材的名字,我该怎么调用它的宽和高呢(在pictures文件夹里)。

最佳答案

查看完整内容

假设图片为 filename = "Graphics/Pictures/temp.png" 一 Bitmap [pre lang="ruby"]#1.1 bitmap = Bitmap.new(filename) w, h = bitmap.width, bitmap.height bitmap.dispose #1.2 bitmap =RPG::Cache.picture(File.basename(filename)) w, h = bitmap.width, bitmap.height #这个不用释放位图[/pre] 二 IO 这个不同的文件类型,位置不一样,以下PNG图片的 [pre lang="ruby"]#2.1 file = File.open(filename) file.pos = 16 text ...
梦石
0
星屑
6483
在线时间
119 小时
注册时间
2020-1-8
回帖
205
发表于 2021-7-17 20:45:19 | 显示全部楼层
本帖最后由 RPGzh500223 于 2021-7-18 18:04 编辑

假设图片为 filename = "Graphics/Pictures/temp.png"
一 Bitmap
[pre lang="ruby"]#1.1
bitmap = Bitmap.new(filename)
w, h = bitmap.width, bitmap.height
bitmap.dispose
#1.2
bitmap =RPG::Cache.picture(File.basename(filename))
w, h = bitmap.width, bitmap.height
#这个不用释放位图[/pre]

二 IO
这个不同的文件类型,位置不一样,以下PNG图片的
[pre lang="ruby"]#2.1
file = File.open(filename)
file.pos = 16
text = file.read(8)
h, w = text.reverse.unpack('LL')
file.close
#2.2
h, w = IO.read(filename, 8, 16).reverse.unpack('LL')
#没有打开流[/pre]

点评

既然有点赞了,就重新排一下版,哈哈。  发表于 2021-7-18 18:06

评分

参与人数 2星屑 +50 赞 +1 收起 理由
RyanBern + 50 认可答案
939034448 + 1 我很赞同

查看全部评分

回复

使用道具 举报

梦石
0
星屑
2876
在线时间
172 小时
注册时间
2020-8-9
回帖
100
 楼主| 发表于 2021-7-17 21:46:29 | 显示全部楼层
RPGzh500223 发表于 2021-7-17 21:23
你星屑都快没了
假设图片为 Graphics/Pictures/temp.png
bitmap = Bitmap.new(" Graphics/Pictures ...

呜呜,太菜了只好多多悬赏,谢谢大佬!
回复

使用道具 举报

梦石
0
星屑
2876
在线时间
172 小时
注册时间
2020-8-9
回帖
100
 楼主| 发表于 2021-7-17 21:50:34 | 显示全部楼层
RPGzh500223 发表于 2021-7-17 20:45
你星屑都快没了
假设图片为 Graphics/Pictures/temp.png
bitmap = Bitmap.new(" Graphics/Pictures ...

大佬,你这个不会是插件脚本吧,我是xp的耶(没看懂怎么用,原谅我这么菜),不过我一个朋友告诉我可以获取几号图片的宽和高
$game_screen.pictures[1],像这样
回复

使用道具 举报

梦石
0
星屑
2876
在线时间
172 小时
注册时间
2020-8-9
回帖
100
 楼主| 发表于 2021-7-17 22:13:32 | 显示全部楼层
RPGzh500223 发表于 2021-7-17 20:45
你星屑都快没了
假设图片为 Graphics/Pictures/temp.png
bitmap = Bitmap.new(" Graphics/Pictures ...

已经成功了!谢谢大佬!我朋友给的办法没生效,不知道是不是我用错了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部