source: trunk/src/testing/app/bitplay/libimg/softpic.h @ 4

Revision 4, 5.3 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

  • Property svn:executable set to *
Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Copyright (C) 2004 Electronic Visualization Laboratory,
5 * University of Illinois at Chicago
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above
15 *    copyright notice, this list of conditions and the following disclaimer
16 *    in the documentation and/or other materials provided with the distribution.
17 *  * Neither the name of the University of Illinois at Chicago nor
18 *    the names of its contributors may be used to endorse or promote
19 *    products derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/
34 *
35 *****************************************************************************/
36
37/*
38 * SoftImage picture file format (.pic).
39 * Transcribed from their printed documentation.
40 *
41 * Ratio: is the aspect ratio of pixels for this image.
42 *  This aspect is the ratio X/Y (if a pixel is 2x wider than tall,
43 *   the ratio is 2.0).  For displaying images on output devices
44 *   with aspect ratio different from 1.0.
45 *
46 * N.B. The pixel ratio is computed according to Full Frame.
47 *
48 * Fields: which scan-lines are present in the picture file.
49 * For normal images this will be Full-frame (3), but if you use video
50 * output you will probably want to double the time sampling and compute
51 * only fields (every alternate scan line).
52 * The field containing the top scan-line is the ODD one (1), the other
53 * is EVEN (2).  The field sequence for NTSC is E-O-E-O...,
54 * while for PAL O-E-O-E...
55 *
56 * Chained: this flag indicates the presence of other packets, generally
57 * it is 1 except for the last packet where it's 0.
58 *
59 * Encoding part: all encoding data are coded byte-by-byte (with some
60 * exceptions) so when we code raw information, we have each byte following
61 * each other.  For example, here is a 512x512 RGBA picture:
62 *
63 * <FILE-CHUNK>
64 *  id = 0x5380f643
65 *  vers = 1.2 (only informatiive info)
66 *  comment = 'none'
67 *
68 * <PICT-CHUNK>
69 *  id='PICT'
70 *  width=512
71 *  height=512
72 *  ratio=1.0
73 *  fields=3 (full-frame)
74 *  padding=(unused)
75 *
76 * <PACK-CHUNK>
77 *  chained=1
78 *  nb bits=8
79 *  type=0
80 *  fields=224 (red+green+blue)
81 *
82 * <PACK-CHUNK>
83 *  chained=0
84 *  nb bits=8
85 *  type=0
86 *  fields=16 (alpha)
87 *
88 * <SCAN-LINE 1>
89 *  R,G,B,... (3x512 bytes)
90 *  A,A,A,... (512 bytes)
91 *
92 * <SCAN-LINE 2>
93 *  R,G,B,...
94 *  A,...
95 * ...
96 *
97 */
98
99/*
100 * All binary files have a similar header:
101 */
102
103struct softhdr {
104        unsigned long id;       /* SoftImage magic number */
105#define SOFT_MAGIC  0x5380f634
106
107        float   version;        /* Version of system that produced it */
108        char    comment[80];    /* user-definable comment */
109};
110
111/*
112 * Then follows the specific chunk for the type of file (here .pic):
113 */
114
115struct softpict {
116        unsigned long   id;     /* 'PICT' */
117#define SPICT_MAGIC     0x50494354
118
119        short   width, height;  /* in pixels */
120        float   ratio;          /* Pixel ratio (X/Y) */
121        short   fields;         /* 1=odd, 2=even, 3=full-frame */
122        short   padding;        /* (to pad this struct to 4-byte multiple) */
123};
124
125/*
126 * Now the associated data.
127 * For a picture file we find first a list of descriptor packets.
128 * A packet describes how the different fields of an image are coded, i.e.
129 * which fields are coded together, the type of data (integer, float &c)
130 * and the compression technique.
131 */
132
133struct softpack {               /* Pack chunk */
134        unsigned char chained;  /* another pack chunk follows this one */
135        unsigned char nbits;    /* bits per data value (8?) */
136        unsigned char type;     /* bit-field describing data format: */
137#define SPICT_UINT      0x00    /* unsigned int */
138#define SPICT_SINT      0x10    /* signed int */
139#define SPICT_FLOAT     0x20    /* float */
140#define SPICT_NOCOMP    0x00    /* uncompressed */
141#define SPICT_PURERLE   0x01    /* "pure" run-length encoded */
142#define SPICT_MIXEDRLE  0x02    /* "mixed" run-length encoded */
143
144        unsigned char fields;   /* bit-field describing what data are present */
145#define SPICT_R         0x80    /*  red */
146#define SPICT_G         0x40    /*  green */
147#define SPICT_B         0x20    /*  blue */
148#define SPICT_A         0x10    /*  alpha */
149#define SPICT_SHADOW    0x08    /*  shadow */
150#define SPICT_DEPTH     0x04    /*  depth */
151#define SPICT_AUX1      0x02    /*  auxiliary 1 */
152#define SPICT_AUX2      0x01    /*  auxiliary 2 */
153
154};
155
Note: See TracBrowser for help on using the repository browser.