private static void Convert(string source, string target) { Console.WriteLine($"{source} -> {target}"); using (var paaStream = File.OpenRead(source)) { using (var img = Image.Load <Rgba32>(source)) { var targetPixels = new ColorRgba32[img.Height, img.Width]; for (int y = 0; y < img.Height; ++y) { for (int x = 0; x < img.Width; ++x) { var srcPixel = img[x, y]; targetPixels[y, x] = new ColorRgba32(srcPixel.R, srcPixel.G, srcPixel.B, srcPixel.A); } } PaaEncoder.WritePAA(target, targetPixels); } } }
protected override void OnSave(Document input, Stream output, SaveConfigToken token, Surface scratchSurface, ProgressEventHandler callback) { input.Flatten(scratchSurface); var pixels = new ColorRgba32[scratchSurface.Width, scratchSurface.Height]; unsafe { for (int y = 0; y < scratchSurface.Height; ++y) { var src = scratchSurface.GetRowPointer(y); for (int x = 0; x < scratchSurface.Width; ++x) { pixels[y, x] = new ColorRgba32((*src).R, (*src).G, (*src).B, (*src).A); src++; } } } using (var writer = new BinaryWriterEx(output, true)) { PaaEncoder.WritePAA(writer, pixels); } }