/// <summary> /// Get the pixel data for a TIM using 15-bit direct color mode. /// </summary> /// <returns>Pixel data.</returns> private IColor[,] GetImageDirect15Bit() { int imageWidth = PixelData.Width; int imageHeight = PixelData.Height; IColor[,] image = new IColor[imageHeight, imageWidth]; for (int i = 0; i < PixelData.Data.Length; i++) { int x = i % imageWidth; int y = i / imageWidth; image[y, x] = new Color16Bit(PixelData.Data[i]); } return(image); }
/// <summary> /// Read a color lookup table from a binary stream. /// </summary> /// <param name="br">The binary stream.</param> public TIMColorLookup(BinaryReader br) { CLUTLength = br.ReadUInt32(); XPosition = br.ReadUInt16(); YPosition = br.ReadUInt16(); Width = br.ReadUInt16(); Height = br.ReadUInt16(); int numColors = Width * Height; Data = new Color16Bit[numColors]; for (int i = 0; i < Data.Length; i++) { Data[i] = new Color16Bit(br); } }
/// <summary> /// Read a color lookup table from a binary stream. /// </summary> /// <param name="br">The binary stream.</param> /// <param name="header">The header of the TIM.</param> public TIMColorLookup(BinaryReader br, TIMHeader header) { _header = header; CLUTLength = br.ReadUInt32(); XPosition = br.ReadUInt16(); YPosition = br.ReadUInt16(); Width = br.ReadUInt16(); Height = br.ReadUInt16(); int singleClutLength = _header.PixelMode == TIMHeader.PixelModes.CLUT4Bit ? 16 : 256; int singleClutLengthBytes = singleClutLength * 2; int numCluts = ((int)CLUTLength - CLUT_HEADER_SIZE_BYTES) / singleClutLengthBytes; Data = new Color16Bit[numCluts, singleClutLength]; for (int i = 0; i < numCluts; i++) { for (int j = 0; j < singleClutLength; j++) { Data[i, j] = new Color16Bit(br); } } }