收藏 分销(赏)

swf文件结构中的基本数据类型.doc

上传人:綻放 文档编号:8915380 上传时间:2025-03-07 格式:DOC 页数:3 大小:497.62KB
下载 相关 举报
swf文件结构中的基本数据类型.doc_第1页
第1页 / 共3页
swf文件结构中的基本数据类型.doc_第2页
第2页 / 共3页
点击查看更多>>
资源描述
CHAPTER 4 Basic Data Types This section describes the basic data types that make up the more complex data structures in the Macromedia Flash (SWF) file format. All other structures in the SWF file format are built on these fundamental types. 这章节描述基本数据类型—在 SWF 文件里可以创建更多复杂数据结构。所有在 SWF 文件里 的其它结构都是由这些基本类型创建的。 Coordinates and twips 坐标和缇 The SWF file format stores all x-y coordinates as integers, usually in a unit of measurement called a twip. In the SWF format, a twip is 1/20th of a logical pixel. A logical pixel is the same as a screen pixel when the file is played at 100% that is, without scaling. — For example, a rectangle 800 twips wide by 400 twips high is rendered as 40 by 20 logical pixels. Fractional pixel sizes are approximated with anti-aliasing. A rectangle 790 by 390 twips (39.5 by 19.5 pixels) appears to have slightly blurred edges. Twips are a good compromise between size and precision. They provide sub-pixel accuracy for zooming and precise placement of objects, while consuming very few bits per coordinate.Coordinates in the SWF file format use the traditional graphics axes: x is horizontal and proceeds from minimum values at the left to maximum values at the right, and y is vertical and proceeds from minimumvalues at the top to maximumvalues at the bottom. swf 文件格式用整数来存储 X-Y 坐标,它的单位默认的是缇(twip),20 twip=1 pixel。在没 有缩放的情况下,就是 100%播放时,swf 中的一个逻辑像素和屏幕上的一个像素是对应的。 使用缇的好处就是能够获得比使用像素更高的精度。 比如,一个 800twips 宽,400twips 高的矩形,就会被解释成 40×20 像素的大小,这时矩形的 边缘是没有锯齿的。如果是 790×390twips(39.5× 19.5 像素)的话,它的就会有轻微的模 糊边缘。 Twips 一个大小与精度之间好的折衷方案。当处理少数坐标位时,它们规定支持了缩放的亚 像素的精确度(sub-pixel)和对象放置的精度。在 swf 的坐标系里面,它采用的是传统的图 像的坐标,x 轴是水平方向,并且是从左到右值是增大的;y 轴是垂直方向的,并且从下到上 是增加的。 Integer types and byte order 整数类型和字节顺序 The SWF file format uses 8-bit, 16-bit, 32-bit, 64-bit, signed, and unsigned integer types. All integer values are stored in the SWF file by using little-endian byte order: the least significant byte is stored first, and the most significant byte is stored last, in the same way as the Intel x86 architecture. The bit order within bytes in the SWF file format is big-endian: the most significant bit is stored first, and the least significant bit is stored last. swf 文件中使用的 8 位、16 位、32 位、64 位有符号和无符号的整数。这些整数在 swf 文件中 是以 little-endian 的顺序来存储的:低字节在前,高字节在后,同样方法应用于 Intel X86 体系 结构。而每个字节的每一位则是按 big-endian 的顺序来排列的:即高位在先,低位在后。 For example:The 32-bit value 0x456e7120 is stored as 20 71 6e 45. The 16-bit value 0xe712 is stored as 12 e7. All integer types must be byte aligned. That is, the first bit of an integer value must be stored in the first bit of a byte in the SWF file. 比如一个 32 位的整数:0x456e7120 ,它在文件中就是以 20 71 6e 45 的格式存储的。一个 16 位的整数:0xe712,它在文件中就是以 12 e7 的格式存储的。这种方式就称为 little-endian。 在 SWF 文件中,所有整数类型必须是字节对齐的。也就是,一个整数值的第一位必须存储在 一个字节的第一位。 little-endian 主要用在我们现在的 PC 的 CPU 中,big-endian 则应用在目前的 Mac 机器中(是指 Power 系列处理器)。 Signed integers are represented by using traditional 2's-complement bit patterns. These are the signed integer representations used on most modern computer platforms. In the 2's complement system, negative numbers have 1 as the first bit, and zero and positive numbers have 0 as the first bit. A negative number, -n, is represented as the bitwise opposite of the positive-zero number n-1. 符号整数通过使用 2 补数位形式(2's-complement bit patterns )来描述的。这种符号整数表示 法用于大多数现代微机平台。 在 2's complement 系统里,负数第一位设为 1,并且 0 和正数第 一位设为 0.一个负数,-n,描述成这个数的正数 n-1 的 反数(取反) 。 Integer Types Type SI8 SI16 SI32 SI8[n] SI16[n] UI8 UI16 UI32 UI8[n] UI16[n] UI24[n] UI32[n] UI64[n] Comment Signed 8-bit integer value 带符号 8 位整数 Signed 16-bit integer value 带符号 16 位整数 Signed 32-bit integer value 带符号 32 位整数 Signed 8-bit array—n is the numberof array elements 带符号 8 位数组,n 是数组元素个数 Signed 16-bit array—n is the is number of array elements 带符号 16 位数组,n 是数组元素个数 Unsigned 8-bit integer value 不带符号 8 位整数 Unsigned 16-bit integer value 不带符号 16 位整数 Unsigned 32-bit integer value 不带符号 32 位整数 Unsigned 8-bit array—n is the number of array elements 不带符号 8 位数组,n 是数组元素个数 Unsigned 16-bit array—n is the number of array elements 不带符号 16 位数组,n 是数组元素个数 Unsigned 24-bit array—n is the number of array elements 不带符号 24 位数组,n 是数组元素个数 Unsigned 32-bit array—n isthe number ofarray elements 不带符号 32 位数组,n 是数组元素个数 Unsigned 64-bit array—n is thenumber of array elements 不带符号 64 位数组,n 是数组元素个数 Fixed-point numbers The SWF file format supports two types of fixed-point numbers: 32 bit and 16 bit.The 32-bit fixed-point numbers are 16.16. That is, the high 16 bits represent the number before the decimal point, and the low 16 bits represent the number after the decimal point. swf 文件格式支持两种类型的定点数: 位定点数和 16 位定点数。 位定点数的格式是 16.16 32 32 格式的,小数点前面和小数点后面的每一部分各占 2 个字节(16 位)。 FIXED values are stored like 32-bit integers in the SWF file (using little-endian byte order) and must be byte aligned. 并且在 SWF 文件里,也是采用了 little-endian 的形式—定点数像 32 位整数一样存储,必须字 节对齐。 For example: The real value 7.5 is equivalent to: 0x0007.8000。This value is stored in the SWF file as: 00 80 07 00SWF 8 and later supports 16-bit 8.8 signed, fixed-point numbers. The high 8 bits represent the number before the decimal point, and the low 8 bits represent the number after the decimal point. FIXED8 values are stored like 16-bit integers in the SWF file (using little-endian byte order) and must be byte aligned. 比如一个 32 位的实数:7.5=0x0007.8000。在文件中就是以 00 80 07 00 的形式存储的。16 位的 定点数和 32 位的是类似的, 采用 8.8 格式, 也是 little-endian 的形式。 位的定点数是在 Flash8 16 及其以后版本中才被支持的。在 SWF 文件里 FIXED8 数据存储时就像 16 位整数一样使用 little-endian 字节序,并且必须字节对齐。 Fixed-Point Types Type Comment FIXED 32-bit 16.16 fixed-point number 32 位定点数 FIXED8 16-bit 8.8 fixed-point number16 位定点数 Floating-point numbers SWF 8 and later supports the use of IEEE Standard 754 compatible floating-point types. Three types of floating-point numbers are supported. Floating-Point Types Type Comment FLOAT16 Half-precision (16-bit) floating-point number FLOAT Single-precision (32-bit)IEEE Standard 754 compatible DOUBLE Double-precision (64-bit) IEEE Standard 754 compatible FLOAT16 is identical to the characteristics of FLOAT except for changes to the number of bits allocated to the exponent and mantissa: ■1 bit for the sign 1 位作为符号位 ■5 bits for the exponent, with an exponent bias of 16 5 位是分配给指数部分,实际的 指数是 5 位数表示的数和 16 的差值; ■10 bits for the mantissa 10 位用来表示尾数 swf8 及其后续的版本中支持和 IEEE Standard 754 兼容的浮点数类型。一共有三种类型,分 别是:Half-precision (16-bit)floating-point number 半精度、Single-precision(32-bit)单精度、 Double-precision(64-bit) 双精度。除了半精度的这种浮点型数据以外,其它两种都符合 IEEE Standard 754 的标准。 半精度的也是和 IEEE Standard 754 类似的,只是改变了标准中分配给尾数和指数的位数。在
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传
相似文档                                   自信AI助手自信AI助手

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服