// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp { using System; using System.IO; using Formats; using ImageSharp.PixelFormats; /// /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha /// packed into a single unsigned integer value. /// public sealed partial class Image { /// /// Loads the image from the given byte array. /// /// The byte array containing image data. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(byte[] data) { return Load(null, data, null); } /// /// Loads the image from the given byte array. /// /// The byte array containing image data. /// The options for the decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(byte[] data, IDecoderOptions options) { return Load(null, data, options); } /// /// Loads the image from the given byte array. /// /// The config for the decoder. /// The byte array containing image data. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(Configuration config, byte[] data) { return Load(config, data, null); } /// /// Loads the image from the given byte array. /// /// The byte array containing image data. /// The decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(byte[] data, IImageDecoder decoder) { return Load(data, decoder, null); } /// /// Loads the image from the given byte array. /// /// The configuration options. /// The byte array containing image data. /// The options for the decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(Configuration config, byte[] data, IDecoderOptions options) { using (MemoryStream ms = new MemoryStream(data)) { return Load(config, ms, options); } } /// /// Loads the image from the given byte array. /// /// The byte array containing image data. /// The decoder. /// The options for the decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options) { using (MemoryStream ms = new MemoryStream(data)) { return Load(ms, decoder, options); } } /// /// Loads the image from the given byte array. /// /// The pixel format. /// The byte array containing image data. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(byte[] data) where TPixel : struct, IPixel { return Load(null, data, null); } /// /// Loads the image from the given byte array. /// /// The pixel format. /// The byte array containing image data. /// The options for the decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(byte[] data, IDecoderOptions options) where TPixel : struct, IPixel { return Load(null, data, options); } /// /// Loads the image from the given byte array. /// /// The pixel format. /// The config for the decoder. /// The byte array containing image data. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(Configuration config, byte[] data) where TPixel : struct, IPixel { return Load(config, data, null); } /// /// Loads the image from the given byte array. /// /// The pixel format. /// The byte array containing image data. /// The decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(byte[] data, IImageDecoder decoder) where TPixel : struct, IPixel { return Load(data, decoder, null); } /// /// Loads the image from the given byte array. /// /// The pixel format. /// The configuration options. /// The byte array containing image data. /// The options for the decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(Configuration config, byte[] data, IDecoderOptions options) where TPixel : struct, IPixel { using (MemoryStream ms = new MemoryStream(data)) { return Load(config, ms, options); } } /// /// Loads the image from the given byte array. /// /// The pixel format. /// The byte array containing image data. /// The decoder. /// The options for the decoder. /// /// Thrown if the stream is not readable nor seekable. /// /// The image public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options) where TPixel : struct, IPixel { using (MemoryStream ms = new MemoryStream(data)) { return Load(ms, decoder, options); } } } }