====== Falcon 4 .APL File Format ====== [[https://www.pmctactical.org/forum/viewforum.php?f=47|Falcon 4.0 Forum]], [[:falcon4|Falcon 4 Home]], [[falcon4:campaign|Falcon 4 Campaign]], [[falcon4:cockpits|Falcon 4 Cockpits]], [[falcon4:database|Falcon 4 Database]], [[falcon4:file_formats|Falcon 4 File Formats]], [[falcon4:srtm|Falcon 4 SRTM Terrain]], [[falcon4:terrain|Falcon 4 Terrain]], [[falcon4:textures|Falcon 4 Textures]], [[falcon4:tools|Falcon 4 Tools]] An APL is a palettized image with the ability to store alpha values in the palette. **NOTE:**The byte order on disk is little-endian. ===== Specification ===== APL file format: ^Data Type^Width(Bytes)^Field Name^Description^ |DWORD|4|MAGIC| = ''%%0x030870%%'', the magic number that identifies this file as an .APL file)| |WORD|2|WIDTH|width of the image in pixels| |WORD|2|HEIGHT|height of the image in pixels| |DWORD[256]|1024|PALETTE| every 4 bytes (i.e. each DWORD) represents a single palette entry; a palette therefore holds 256 entries, numbered 0-255.\\ The high-order byte = ALPHA, and the next lower-order 3 bytes are Red, Green, and Blue, respectively. | |BYTE[]|WIDTH*HEIGHT|IMAGEDATA|Each byte in the IMAGEDATA section represents one pixel in the image; each byte's value is an offset into the palette array (0-255)| ===== Reading an .APL file ===== * check the first DWORD (4 bytes) to see that it equals ''%%0x030870%%''; if so, this is an APL file\\ * then check the next WORD (2 bytes), this is the width, in pixels, of the image\\ * then check the next WORD (2 bytes), this is the height, in pixels, of the image\\ * then load the next 256 DWORDs (1024 bytes) into an array, where each DWORD (4 bytes) represents a single palette entry. Each pallete entry consists of 4 bytes (alpha, red, green, and blue, from high-order to low-order, respectively). \\ * the next (width * height) bytes represent the image data itself, one byte per pixel, with one row's worth of pixel data coming first, then the next row's worth of pixel data, etc. The first byte represents the upper-left pixel in the image/texture; the last byte represents the lower-left pixel in the image/texture. The byte value associated with each pixel, provides an index into the palette array, telling you which palette entry to use for determining the color to use for rendering that pixel. Just look up the corresponding palette entry to get the color data for that pixel, as well as the alpha channel value. If the alpha component is set to ''%%0x80%%'', then this magic value means do not use ALPHA.