MASK LFD Resource Type Author: Jagged Fel (jaggedfel621@gmail.com) Site: http://idmr.empirereborn.net Updated: 2009.10.05 ===== The MASK resource is image data found primarily in cockpit LFD files. These files do not contain RMAPs, although are comprised of a PANL, MASK and PLTT. The MASK is a monochrome image which tells the program where "empty" pixels are so that you can actually see out of the cockpit. ===== MASK Structure The following values are used through this and all of my file definitions unless otherwise specified: NAME LENGTH DESC ---- ------ ---- BYTE 1 unsigned 8-bit CHAR 1 ASCII character SHORT 2 signed Int16 INT 4 signed Int32 -- Header Row[] SHORT Reserved (0) -- struct Header (size 0x10) { 0x0 CHAR[4] "MASK" 0x4 CHAR[8] Name 0xC INT Length } struct Row { BYTE StartPixel BYTE[] Ranges } ===== MASK Details Unlike most image resources found in the LFDs, MASK does not have a Width and Height defined in the resource itself. The size is defined in the cockpit .INT file under the appropriate view subsection. The sizes can be determined computationally, although complicated mask patterns increase the difficulty of determining the image size correctly. The StartPixel value is either 01 or FF, and decides which color the first Range will be. 01 starts black, FF starts white. Range values are the length of pixels to be the current color. So if a row starts as 01 32 40 05, then the row will be 50px black, 64px white, 5px black. But what happens when you need more than 255px? The Range value of 00 adds 256 to the next value, and they can be stacked. So a row of FF 00 00 80 is 640px of white (256 + 256 + 128). Important note: A row cannot contain a Range of 256px (00) or 512 (00 00), for there is no following value for the 00 to be added to. The only exception is if the row *ends* in a zero Range. In this case, typically a 01 is used as a "throw away" pixel. In GUNBT08.LFD, the MASK therein contains a line of FF 00 80 00 01 which comes out to 641px, instead of the 640px of the image. The extra pixel is not displayed, though it must be accounted for while processing the image (TIEEdit does not, and will display the MASK incorrectly). =====