/// <summary> /// Creates a new <see cref="MorphLineStyle"/> instance. /// </summary> /// <param name="startWith">Start with.</param> /// <param name="endWith">End with.</param> /// <param name="startColor">Color of the start.</param> /// <param name="endColor">Color of the end.</param> public MorphLineStyle(ushort startWith, ushort endWith, RGBA startColor, RGBA endColor) { this.startWith = startWith; this.endWith = endWith; this.startColor = startColor; this.endColor = endColor; }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> public void ReadData(BufferedBinaryReader binaryReader) { startRatio = binaryReader.ReadByte(); startColor = new RGBA(); startColor.ReadData(binaryReader); endRatio = binaryReader.ReadByte(); endColor = new RGBA(); endColor.ReadData(binaryReader); }
/// <summary> /// Creates a new <see cref="MorphGradRecord"/> instance. /// </summary> /// <param name="startRatio">Start ratio.</param> /// <param name="startColor">Color of the start.</param> /// <param name="endRatio">End ratio.</param> /// <param name="endColor">Color of the end.</param> public MorphGradRecord(byte startRatio, RGBA startColor, byte endRatio, RGBA endColor) { this.startRatio = startRatio; this.startColor = startColor; this.endRatio = endRatio; this.endColor = endColor; }
/// <summary> /// Creates a new <see cref="SolidFill"/> instance. /// </summary> /// <param name="fillColor">Color of the fill.</param> public SolidFill(RGBA fillColor) { this.rgbColor = fillColor; fillStyleType = (byte)FillStyleType.SolidFill; }
/// <summary> /// Creates a new <see cref="MorphSolidFill"/> instance. /// </summary> /// <param name="startColor">Color of the start.</param> /// <param name="endColor">Color of the end.</param> public MorphSolidFill(RGBA startColor, RGBA endColor) { this.startColor = startColor; this.endColor = endColor; this.fillStyleType = (byte)MorphFillStyleType.SolidFill; }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> public void ReadData(BufferedBinaryReader binaryReader) { fillStyleType = binaryReader.ReadByte(); startColor = null; endColor = null; if (fillStyleType == (byte)MorphFillStyleType.SolidFill) { startColor = new RGBA(); startColor.ReadData(binaryReader); endColor = new RGBA(); endColor.ReadData(binaryReader); } startGradientMatrix = null; endGradientMatrix = null; MorphGradientCollection gradient = null; if (fillStyleType == (byte)MorphFillStyleType.LinearGradientFill || fillStyleType == (byte)MorphFillStyleType.RadialGradientFill) { startGradientMatrix = new Matrix(); startGradientMatrix.ReadData(binaryReader); endGradientMatrix = new Matrix(); endGradientMatrix.ReadData(binaryReader); gradient = new MorphGradientCollection(); gradient.ReadData(binaryReader); } bitmapId = 0; startBitmapMatrix = null; endBitmapMatrix = null; if (fillStyleType == (byte)MorphFillStyleType.RepeatingBitmap || fillStyleType == (byte)MorphFillStyleType.ClippedBitmapFill || fillStyleType == (byte)MorphFillStyleType.NonSmoothedClippedBitmap || fillStyleType == (byte)MorphFillStyleType.NonSmoothedRepeatingBitmap) { bitmapId = binaryReader.ReadUInt16(); startBitmapMatrix = new Matrix(); startBitmapMatrix.ReadData(binaryReader); endBitmapMatrix = new Matrix(); endBitmapMatrix.ReadData(binaryReader); } }
/// <summary> /// Construct a new DefineBitsLossLess2Tag object /// from an image object. /// </summary> /// <param name="characterId">Character id.</param> /// <param name="image">Image.</param> /// <returns></returns> public static DefineBitsLossLess2Tag FromImage(ushort characterId, Image image) { if (image.RawFormat.Equals(ImageFormat.Bmp) == false && image.RawFormat.Equals(ImageFormat.MemoryBmp) == false) throw new InvalidImageFormatException(); Bitmap bitmap = (Bitmap)image; byte format = 0; PixelFormat pxFormat = image.PixelFormat; if (pxFormat == PixelFormat.Format8bppIndexed) format = 3; else if (pxFormat == PixelFormat.Format16bppRgb555 || pxFormat == PixelFormat.Format16bppRgb565) format = 4; else if (pxFormat == PixelFormat.Format24bppRgb) format = 5; else throw new InvalidPixelFormatException(); DefineBitsLossLess2Tag bmp = new DefineBitsLossLess2Tag(); bmp.CharacterId = characterId; bmp.BitmapFormat = format; bmp.BitmapWidth = (ushort)image.Width; bmp.BitmapHeight = (ushort)image.Height; int imageSize = bitmap.Width * bitmap.Height; if (bmp.BitmapFormat == 3) { //TODO } else if (bmp.BitmapFormat == 4 || bmp.BitmapFormat == 5) { RGBA[] bitmapPixelData = new RGBA[imageSize]; int k = 0; for (int i = 0; i < bitmap.Height; i++) { for (int j = 0; j < bitmap.Width; j++) { Color color = bitmap.GetPixel(j, i); bitmapPixelData[k] = new RGBA((byte)color.R, (byte)color.G, (byte)color.B, (byte)color.A); k++; } } bmp.AlphaBitmapData = new AlphaBitmapData(bitmapPixelData); } return bmp; }
/// <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); characterId = binaryReader.ReadUInt16(); rect = new Rect(); rect.ReadData(binaryReader); BitArray ba = BitParser.GetBitValues(new byte[1]{ binaryReader.ReadByte() }); bool hasText = ba.Get(0); //binaryReader.ReadBoolean(); wordWrap = ba.Get(1); //binaryReader.ReadBoolean(); multiline = ba.Get(2); //binaryReader.ReadBoolean(); password = ba.Get(3); //binaryReader.ReadBoolean(); readOnly = ba.Get(4); //binaryReader.ReadBoolean(); bool hasTextColor = ba.Get(5); //binaryReader.ReadBoolean(); bool hasMaxLength = ba.Get(6); //binaryReader.ReadBoolean(); bool hasFont = ba.Get(7); //binaryReader.ReadBoolean(); //binaryReader.SynchBits(); ba = BitParser.GetBitValues(new byte[1]{ binaryReader.ReadByte() }); //binaryReader.ReadBoolean(); //Reserved autoSize = ba.Get(1); //binaryReader.ReadBoolean(); bool hasLayout = ba.Get(2); //binaryReader.ReadBoolean(); noSelect = ba.Get(3); //binaryReader.ReadBoolean(); border = ba.Get(4); //binaryReader.ReadBoolean(); //binaryReader.ReadBoolean(); //Reserved html = ba.Get(6); //binaryReader.ReadBoolean(); usedOutlines = ba.Get(7); //binaryReader.ReadBoolean(); if (hasFont) { fontId = binaryReader.ReadUInt16(); fontHeight = binaryReader.ReadUInt16(); } if (hasTextColor) { textColor = new RGBA(); textColor.ReadData(binaryReader); } if (hasMaxLength) maxLenght = binaryReader.ReadUInt16(); if (hasLayout) { align = binaryReader.ReadByte(); leftMargin = binaryReader.ReadUInt16(); rightMargin = binaryReader.ReadUInt16(); indent = binaryReader.ReadUInt16(); leading = binaryReader.ReadUInt16(); } variableName = binaryReader.ReadString(); if (hasText) initialText = binaryReader.ReadString(); }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> public void ReadData(BufferedBinaryReader binaryReader) { startWith = binaryReader.ReadUInt16(); endWith = binaryReader.ReadUInt16(); startColor = new RGBA(); startColor.ReadData(binaryReader); endColor = new RGBA(); endColor.ReadData(binaryReader); }
/// <summary> /// Creates a new <see cref="AlphaBitmapData"/> instance. /// </summary> /// <param name="bitmapPixelData">Bitmap pixel data.</param> public AlphaBitmapData(RGBA[] bitmapPixelData) { this.bitmapPixelData = bitmapPixelData; }
/// <summary> /// Creates a new <see cref="AlphaColorMapData"/> instance. /// </summary> /// <param name="colorTableRgb">Color table RGB.</param> /// <param name="colorMapPixelData">Color map pixel data.</param> public AlphaColorMapData(RGBA[] colorTableRgb, byte[] colorMapPixelData) { this.colorTableRgb = colorTableRgb; this.colorMapPixelData = colorMapPixelData; }