gpt4 book ai didi

actionscript-3 - 如何从 AS3 中的字节数组获取 GIF 图像尺寸?

转载 作者:行者123 更新时间:2023-12-02 00:48:55 25 4
gpt4 key购买 nike

如何从原始字节数组中获取 GIF 图像尺寸?

这是 related问题。我试图找出是否有一串包含宽度和高度的字节。

我找到了 this GIF 格式的页面,但我不确定如何破译它。貌似位置6和位置8包含了宽和高?

最佳答案

我想这就是您要找的:http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp

字节 6-7(从 0 开始的索引)表示宽度,字节 8-9 表示高度。在那种情况下:

var source:ByteArray;
var aHeight:int;
var aWidth:int;

source.position = 6;

aWidth = source.readUnsignedByte();
aWidth += source.readUnsignedByte() << 8;

aHeight = source.readUnsignedByte();
aHeight += source.readUnsignedByte() << 8;

或者只使用 readShort 用于在不进行位移的情况下获取双字节值(16 位)<< ...

aWidth  = source.readShort();
aHeight = source.readShort();

关于actionscript-3 - 如何从 AS3 中的字节数组获取 GIF 图像尺寸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41670780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com