Windows
Alias 相机深度文件包含与从该相机创建的图像相对应的深度信息。相机深度文件用于进行渲染后的三维合成。该文件包含一个幻数、一个 X 分辨率、一个 Y 分辨率和一个浮点深度值的阵列。
| 字节 | 标头值 | 注释 | C 类型 |
| 0,1,2,3 | magic number | 唯一标识此类文件 | int |
| 4,5 | width | X 分辨率(像素) | short |
| 6,7 | height | Y 分辨率(像素) | short |
Alias 相机深度文件的幻数为 55655。文件的其余部分包含一个按行顺序排列的浮点值 X * Y 阵列。
以下 C 代码示例说明了如何读取相机深度文件:
filein = open( infilename, O_RDONLY );
read( filein, &magic, sizeof( int ) ); /* magic number */
if ( magic != 55655 ) {
fprintf( stderr,”given input file '%s' does not have proper magic number (55655)\n”, infilename );
exit(0);
}
read ( filein, &width, sizeof(short) ); /* Xres */
read ( filein, &height, sizeof(short) ); /* Yres */
size = width * height;
buffer = (float *)malloc ( size * sizeof( float ) );
read( filein, buffer, sizeof(float)*size2 ); /* fill the array */
close( filein );
for (i = 0; i < height; ++i) {
for (j = 0; j < width; ++j) {
/* Do something to the pixel. */
}
}