ShockwaveFlash 1.0.0
See the version list below for details.
dotnet add package ShockwaveFlash --version 1.0.0
NuGet\Install-Package ShockwaveFlash -Version 1.0.0
<PackageReference Include="ShockwaveFlash" Version="1.0.0" />
<PackageVersion Include="ShockwaveFlash" Version="1.0.0" />
<PackageReference Include="ShockwaveFlash" />
paket add ShockwaveFlash --version 1.0.0
#r "nuget: ShockwaveFlash, 1.0.0"
#:package ShockwaveFlash@1.0.0
#addin nuget:?package=ShockwaveFlash&version=1.0.0
#tool nuget:?package=ShockwaveFlash&version=1.0.0
ShockwaveFlash
A fast, allocation-light reader and writer for the SWF (Shockwave Flash) binary format, written for .NET 10.
Disassemble a .swf file into a strongly-typed tag tree, inspect or edit it in code, then assemble it back. Re-assembly is byte-identical to the input it was parsed from — validated by round-tripping a real corpus of production files.
Features
- Reader and writer for the SWF container and its tag stream — every supported tag round-trips.
- Byte-identical assembly: parse then assemble reproduces the original bytes exactly.
- Broad tag coverage (shapes, fonts, text, sounds, bitmaps, sprites, buttons, morph shapes, video, ABC, filters, control tags). Unknown tags are preserved verbatim, so nothing is lost on round-trip.
- Exact fixed-point types (
Fixed1616.16,Fixed88.8) — no lossyfloatconversions in the wire model. - Compression: reads
FWS(uncompressed),CWS(zlib) andZWS(LZMA); writes uncompressed and zlib. - Typed exceptions (
SwfFormatException,SwfTruncatedException,SwfUnsupportedException,SwfCompressionException) for precise error handling on malformed input. - No
unsafein your code path, noSpanplumbing — the public surface works overReadOnlyMemory<byte>.
Install
dotnet add package ShockwaveFlash
Quick start
Read
using ShockwaveFlash;
var bytes = File.ReadAllBytes("movie.swf");
var swf = ShockwaveFlashFile.Disassemble(bytes);
Console.WriteLine($"SWF v{swf.Header.Version} ({swf.Header.Compression})");
Console.WriteLine($"Frame size : {swf.Header.FrameSize}");
Console.WriteLine($"Frame rate : {swf.Header.FrameRate.ToSingle()} fps");
Console.WriteLine($"Frames : {swf.Header.FrameCount}");
Console.WriteLine($"Tags : {swf.Tags.Count}");
foreach (var tag in swf.Tags)
Console.WriteLine($" {tag.Metadata.Code} ({tag.Metadata.Length} bytes)");
Write
ShockwaveFlashFile is an immutable record, so edits are expressed with with:
using ShockwaveFlash;
using ShockwaveFlash.Tags;
var swf = ShockwaveFlashFile.Disassemble(File.ReadAllBytes("movie.swf"));
var trimmed = swf with
{
Tags = swf.Tags.Where(tag => tag.Metadata.Code is not TagCode.Metadata).ToList()
};
ReadOnlyMemory<byte> output = trimmed.Assemble();
File.WriteAllBytes("movie.trimmed.swf", output.ToArray());
Round-trip
var original = File.ReadAllBytes("movie.swf");
var rebuilt = ShockwaveFlashFile.Disassemble(original).Assemble();
// Reproduces the original bytes exactly.
bool identical = rebuilt.Span.SequenceEqual(original);
Error handling
Malformed input throws a SwfException (or one of its derived types) rather than corrupting state:
using ShockwaveFlash.Exceptions;
try
{
var swf = ShockwaveFlashFile.Disassemble(bytes);
}
catch (SwfTruncatedException)
{
// the buffer ended before a record was complete
}
catch (SwfFormatException)
{
// the bytes are not a valid SWF
}
License
MIT © Aerafal
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ShockwaveFlash:
| Package | Downloads |
|---|---|
|
ShockwaveFlash.Avm1
AVM1 (ActionScript 1/2 bytecode) decoder, encoder and data evaluator for the ShockwaveFlash SWF library. Disassemble DoAction bytecode to a typed action model, evaluate data scripts to a value tree, and write edits back. |
|
|
ShockwaveFlash.Rendering
Render SWF characters (shapes, sprites, timelines, images) parsed by ShockwaveFlash to SVG and to raster images (PNG/JPEG/WebP/GIF) through a native, cross-platform Skia backend. |
GitHub repositories
This package is not used by any popular GitHub repositories.