.rgba files are intentionally very simple. The idea is to provide a file format that software can easily read and write in order to exchange images with iToolBox through normal filesystem operations.
An .rgba file's size will always be 24+(N*width*height), where "*" means multiplied by, and N is 4 when the .rgba file is 32 bits in depth, and 8 when it is 64 bits in depth.
Rules: ------ TAGs are 8, 8-bit chars Unused bytes in a tag are set to zero Quotes are used here only to indicate ASCII characters are being represented, they are not in the TAGs Commas are used here only to indicate the next byte follows, they are not in the TAGs For 32-bit depth .rgba files: Channel values are one byte each RGB data bytes are zero for minimum channel value, and 255 for maximum channel value Alpha data bytes are zero for fully transparent, and 255 for fully opaque For 64-bit depth .rgba files: Channel values are two bytes each, stored most significant byte first RGB data words are zero for minimum channel value, and 65535 for maximum channel value Alpha data words are zero for fully transparent, and 65535 for fully opaque RGB data is not pre-multiplied by the Alpha value File content: ------------- first, file ID { TAG file-id: either: "RAW32XY",0 or: "RAW64XY",0 } Next, image dimensions: { TAG width: ASCII number, one or larger, zero-terminated and filled, e.g. "640",0,0,0,0,0 TAG height: ASCII number, one or larger, zero-terminated and filled, e.g. "480",0,0,0,0,0 } either: 32-bit Image data (for files ID'd as "RAW32XY"): { (width x height) instances of four 8-bit, unsigned data bytes in the order Red,Green,Blue,Alpha } or: 64-bit Image data (for files ID'd as "RAW64XY"): { (width x height) instances of four 16-bit (2 byte, MSB first), unsigned data words in the order Red,Green,Blue,Alpha }
To validate an .rgba file:
If this all checks out, the .rgba image file is valid and the data may be read.
Please consider supporting my iToolBox development efforts with a small PayPal donation. |