protected static SwfStreamReader GetSwfStreamReader(SwfFileInfo info, Stream stream) { if (info.Format == SwfFormat.Unknown) { throw new NotSupportedException("Illegal file format"); } if (info.Format == SwfFormat.FWS) { return(new SwfStreamReader(stream)); } var mem = new MemoryStream(); SwfZip.Decompress(stream, mem, info.Format); return(new SwfStreamReader(mem)); }
private static Stream DecompressIfNeeded(SwfFileInfo info, Stream stream) { if (info.Format == SwfFormat.Unknown) { throw new NotSupportedException("Illegal file format"); } if (info.Format == SwfFormat.FWS) { return(stream); } var mem = new MemoryStream(); SwfZip.Decompress(stream, mem, info.Format); return(mem); }
protected static Bitmap SetAlphas(Bitmap bmp, byte[] compressedAlpha) { var alpha = SwfZip.Decompress(compressedAlpha, SwfFormat.CWS); var index = 0; var res = new Bitmap(bmp.Width, bmp.Height, PixelFormat.Format32bppArgb); for (var y = 0; y < bmp.Height; y++) { for (var x = 0; x < bmp.Width; x++) { var clr = bmp.GetPixel(x, y); clr = Color.FromArgb(alpha[index], clr); res.SetPixel(x, y, clr); index++; } } return(res); }