public static byte[] Convert(ImageFormat destinationFormat, byte[] sourcePixels, ImageFormat sourceFormat) { if( destinationFormat.Depth == 32 && sourceFormat.Depth == 24 ) { return ConvertFrom24BppTo32Bpp(sourcePixels, destinationFormat.PixelFormat, sourceFormat.PixelFormat); } return null; }
public static bool IsSupported(this ImageFormat[] formats, ImageFormat desiredFormat) { for( var formatIndex=0; formatIndex<formats.Length; formatIndex++ ) { if( formats[formatIndex].Equals(desiredFormat) ) { return true; } } return false; }
public static ImageFormat GetBestSuitedFormat(this ImageFormat[] formats, ImageFormat desiredFormat) { // Todo: Also look for PixelFormat - if there is a format that matches with both Depth and PixelFormat, choose this first. // Do a prioritizing of formats and depths - needs some thinking. :) for (var formatIndex = 0; formatIndex < formats.Length; formatIndex++) { if (formats[formatIndex].Depth >= desiredFormat.Depth) { return formats[formatIndex]; } } return null; }
public void SetFrame(ImageFormat format, byte[] frameBytes, ImagePalette palette) { var targetFormat = ImageFormats.GetBestSuitedFormat(format); var canConvertFrom = ImageHelper.CanConvertFrom(format); if (null == targetFormat || !canConvertFrom ) { throw new UnsupportedImageFormatException(format); } // Special case - no need to convert if( targetFormat.Equals(format)) { SetFrame(frameBytes); } else { var convertedFrameBytes = ImageHelper.Convert(targetFormat, frameBytes, format); SetFrame(convertedFrameBytes); } }
public static byte[] Convert(ImageFormat destinationFormat, byte[] sourcePixels, ImageFormat sourceFormat, ImagePalette palette) { throw new NotImplementedException(); }
public static bool CanConvertFrom(ImageFormat format) { return SupportedFromFormats.IsSupported(format); }
public void SetFrame(ImageFormat format, byte[] frameBytes) { SetFrame(format,frameBytes,null); }
public UnsupportedImageFormatException(ImageFormat format) : base("Unsupported ImageFormat ("+format.ToString()+")") { }
public UnsupportedImageFormatException(ImageFormat format, string message) : base("Unsupported ImageFormat (" + format.ToString() + ") - Message: "+message) { }
public void SetFrame(ImageFormat format, byte[] frameBytes, ImagePalette palette) { }
public void SetFrame(ImageFormat format, byte[] frameBytes) { }