§ 41 - .rgba image format

.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:

  1. Confirm the file size is equal to or larger than 28 bytes in size
    (that would be a 1 by 1, 32-bit image, the minimum size a valid .rgba file can be)
  2. Read the file-id TAG and verify it is either "RAW32XY" or "RAW64XY"
  3. Parse the width and height tags
  4. Make sure both width and height are positive numbers above zero
    • If parsing "RAW32XY"
      • Multiply width times height times four, add 24, and verify that this is the file size.
    • If parsing "RAW64XY"
      • Multiply width times height times eight, add 24, and verify that this is the file size.

If this all checks out, the .rgba image file is valid and the data may be read.

Document Keyboard Navigation
, Previous Page . Next Page
t TOC i Index k Keyboard o Operators g Glossary c Changes

Valid HTML 4.01 Loose
 

This manual was generated with wtfm
wtfm uses aa_macro and SqLite
wtfm and aa_macro are coded in python 2.7
iToolBox 3.12
This Documentation and Associated Application Executables are Public Domain
Please consider supporting my iToolBox development efforts with a small PayPal donation.