public void AddMeshData(MeshData data, ColorMapData colormapdata, int lodlevel = 1) { if (data == null) { return; } mesh.AddMeshData(data); }
/// <summary> /// constructor. /// </summary> /// <param name="characterId">id for this character</param> /// <param name="bitmapFormat">Format of compressed data</param> /// <param name="bitmapWidth">Width of bitmap image</param> /// <param name="bitmapHeight">Height of bitmap image</param> /// <param name="bitmapColorTableSize">actual number of colors in the color table</param> /// <param name="zlibBitmapData">zlib compressed bitmap data</param> public DefineBitsLossLessTag(ushort characterId, byte bitmapFormat, ushort bitmapWidth, ushort bitmapHeight, byte bitmapColorTableSize, ColorMapData zlibBitmapData) { _characterId = characterId; _bitmapFormat = bitmapFormat; _bitmapWidth = bitmapWidth; _bitmapHeight = bitmapHeight; _bitmapColorTableSize = bitmapColorTableSize; _colorMapData = zlibBitmapData; _tagCode = (int)TagCodeEnum.DefineBitsLossLess; }
/// <summary> /// Decompiles to stream. /// </summary> /// <param name="stream">Stream.</param> private void DecompileToStream(Stream stream) { if (BitmapFormat == 3) { //ColorMapData ColorMapData mapData = ColorMapData; Bitmap bmp = new Bitmap((int)BitmapWidth, (int)BitmapHeight); int k = 0; for (int i = 0; i < (int)BitmapHeight; i++) { for (int j = 0; j < (int)BitmapWidth; j++) { int index = (int)mapData.ColorMapPixelData[k]; if (index >= 0 && index < mapData.ColorTableRGB.Length) { bmp.SetPixel(j, i, mapData.ColorTableRGB[index].ToWinColor()); } else { bmp.SetPixel(j, i, Color.Black); } k++; } } bmp.Save(stream, ImageFormat.Bmp); bmp.Dispose(); } else { //BitmapData BitmapColorData bitmapData = BitmapData; Pix[] data = null; if (BitmapFormat == 5) { data = bitmapData.bitmapPixelDataPix24; } else { data = bitmapData.bitmapPixelDataPix15; } if (data == null) { return; } Bitmap bmp = new Bitmap((int)BitmapWidth, (int)BitmapHeight); int k = 0; for (int i = 0; i < (int)BitmapHeight; i++) { for (int j = 0; j < (int)BitmapWidth; j++) { if (k < data.Length) { bmp.SetPixel(j, i, data[k].PixelColor); } else { bmp.SetPixel(j, i, Color.Black); } k++; } } bmp.Save(stream, ImageFormat.Bmp); bmp.Dispose(); } }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); int beforePos = (int)binaryReader.BaseStream.Position; int toReaded = (int)rh.TagLength - 7; _characterId = binaryReader.ReadUInt16(); _bitmapFormat = binaryReader.ReadByte(); _bitmapWidth = binaryReader.ReadUInt16(); _bitmapHeight = binaryReader.ReadUInt16(); _bitmapColorTableSize = 0; if (_bitmapFormat == 3) { _bitmapColorTableSize = binaryReader.ReadByte(); toReaded--; } if (_bitmapFormat == 3) { _colorMapData = new ColorMapData(); _colorMapData.ReadData(binaryReader, _bitmapColorTableSize, _bitmapWidth, _bitmapHeight, toReaded); } else if (_bitmapFormat == 4 || _bitmapFormat == 5) { int imageSize = _bitmapWidth * _bitmapHeight; int uncompressedSize = imageSize; if (_bitmapFormat == 4) { uncompressedSize *= 2; } else { uncompressedSize *= 4; } byte[] uncompressed = new byte[uncompressedSize]; byte[] compressed = binaryReader.ReadBytes(toReaded); uncompressed = DeflatorWraper.Decompress(compressed); _bitmapColorData = null; if (_bitmapFormat == 4) { Pix15[] bitmapPixelData = new Pix15[imageSize]; for (int i = 0, j = 0; i < imageSize; i++, j += 2) { byte[] data = new byte[2] { uncompressed[j], uncompressed[j + 1] }; bitmapPixelData[i] = new Pix15(data); } _bitmapColorData = new BitmapColorData(bitmapPixelData); } else { Pix24[] bitmapPixelData = new Pix24[imageSize]; for (int i = 0, j = 0; i < imageSize; i++, j += 4) { byte reserved = uncompressed[j]; byte red = uncompressed[j + 1]; byte green = uncompressed[j + 2]; byte blue = uncompressed[j + 3]; bitmapPixelData[i] = new Pix24(red, green, blue); } _bitmapColorData = new BitmapColorData(bitmapPixelData); } } }