Browse Source

AoT seed image encoders as well as decoders

pull/785/head
Shane Woolcock 8 years ago
parent
commit
520d181b0d
  1. 22
      src/ImageSharp/Advanced/AotCompilerTools.cs

22
src/ImageSharp/Advanced/AotCompilerTools.cs

@ -43,10 +43,10 @@ namespace SixLabors.ImageSharp.Advanced
System.Runtime.CompilerServices.Unsafe.SizeOf<TPixel>(); System.Runtime.CompilerServices.Unsafe.SizeOf<TPixel>();
AotDecoder<TPixel>(new Formats.Png.PngDecoder()); AotCodec<TPixel>(new Formats.Png.PngDecoder(), new Formats.Png.PngEncoder());
AotDecoder<TPixel>(new Formats.Bmp.BmpDecoder()); AotCodec<TPixel>(new Formats.Bmp.BmpDecoder(), new Formats.Bmp.BmpEncoder());
AotDecoder<TPixel>(new Formats.Gif.GifDecoder()); AotCodec<TPixel>(new Formats.Gif.GifDecoder(), new Formats.Gif.GifEncoder());
AotDecoder<TPixel>(new Formats.Jpeg.JpegDecoder()); AotCodec<TPixel>(new Formats.Jpeg.JpegDecoder(), new Formats.Jpeg.JpegEncoder());
// TODO: Do the discovery work to figure out what works and what doesn't. // TODO: Do the discovery work to figure out what works and what doesn't.
} }
@ -122,11 +122,12 @@ namespace SixLabors.ImageSharp.Advanced
} }
/// <summary> /// <summary>
/// This method pre-seeds the decoder for a given pixel format in the AoT compiler for iOS. /// This method pre-seeds the decoder and encoder for a given pixel format in the AoT compiler for iOS.
/// </summary> /// </summary>
/// <param name="decoder">The image decoder to seed..</param> /// <param name="decoder">The image decoder to seed.</param>
/// <param name="encoder">The image encoder to seed.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
private static void AotDecoder<TPixel>(IImageDecoder decoder) private static void AotCodec<TPixel>(IImageDecoder decoder, IImageEncoder encoder)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
try try
@ -136,6 +137,13 @@ namespace SixLabors.ImageSharp.Advanced
catch catch
{ {
} }
try
{
encoder.Encode<TPixel>(null, null);
}
catch
{
}
} }
} }
} }
Loading…
Cancel
Save