// Spludlow Software // Copyright © Samuel P. Ludlow 2020 All Rights Reserved // Distributed under the terms of the GNU General Public License version 3 // Distributed WITHOUT ANY WARRANTY; without implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE // https://www.spludlow.co.uk/LICENCE.TXT // The Spludlow logo is a registered trademark of Samuel P. Ludlow and may not be used without permission // v1.14 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing.Imaging; using System.Reflection; namespace Spludlow.Drawing { public class BitmapFormats { public int Dpi; public PixelFormat PixelFormat; public ImageFormat ImageFormat; public static Spludlow.Variations PixelFormatVariations = new Spludlow.Variations(new string[] { "Format16bppGrayScale 16 grey", // 16 bit (2 byte) greyscale 65536 "Format24bppRgb 24 rgb", // 24 bit RGB "Format32bppArgb 32 argb", // 32 bit ARGB "Format1bppIndexed 1 mono", // 2 colours "Format4bppIndexed 4 index16", // 16 colours "Format8bppIndexed 8 index256", // 256 (includeds 8 bit grey) }); public static Spludlow.Variations ImageFormatVariations = new Spludlow.Variations(new string[] { "Bmp", "Gif", "Jpeg jpg", "Png", "Tiff tif", }); public BitmapFormats(int dpi, PixelFormat pixelFormat, ImageFormat imageFormat) { this.Dpi = dpi; this.PixelFormat = pixelFormat; this.ImageFormat = imageFormat; } public static ImageFormat ParseImageFormat(string text) { text = ImageFormatVariations.Match(text); Type type = typeof(ImageFormat); return (ImageFormat)type.InvokeMember(text, BindingFlags.GetProperty, null, type, null); } public static PixelFormat ParsePixelFormat(string text) { text = PixelFormatVariations.Match(text); return (PixelFormat)Enum.Parse(typeof(PixelFormat), text); } } }