/// <summary> /// Converts 8-bit gray intensity to the 8-bit Bgra color. /// </summary> /// <param name="gray">Source color.</param> /// <param name="bgra">Destination color.</param> public static void Convert(Gray <byte> gray, ref Bgra <byte> bgra) { bgra.B = gray.Intensity; bgra.G = gray.Intensity; bgra.R = gray.Intensity; bgra.A = System.Byte.MaxValue; }
public static void Convert(Bgr <byte> bgr, ref Bgra <byte> bgra, byte opacity = System.Byte.MaxValue) { bgra.B = bgr.B; bgra.G = bgr.G; bgra.R = bgr.R; bgra.A = opacity; }
/// <summary> /// Converts 8-bit Bgra to 8-bit Gray. /// </summary> /// <param name="bgra">Source color.</param> /// <param name="gray">Destination color.</param> public static void Convert(Bgra <byte> bgra, ref Gray <byte> gray) { Bgr <byte> bgr = default(Bgr <byte>); Convert(bgra, ref bgr); Bgr <byte> .Convert(bgr, ref gray); }
public static void Convert(Bgr <byte> bgr, ref Bgra <byte> bgra) { bgra.B = bgr.B; bgra.G = bgr.G; bgra.R = bgr.R; bgra.A = System.Byte.MaxValue; }
/// <summary> /// Converts an image to an bitmap. /// </summary> /// <param name="img">Input image.</param> /// <returns>Bitmap</returns> public static Bitmap ToBitmap(this Bgra<short>[,] img) { Bitmap bmp = null; using (var uImg = img.Lock()) { bmp = toBitmap(uImg, PixelFormat.Format64bppArgb); } return bmp; }
/// <summary> /// Converts an image to an bitmap. /// </summary> /// <param name="img">Input image.</param> /// <returns>Bitmap</returns> public static Bitmap ToBitmap(this Bgra <byte>[,] img) { Bitmap bmp = null; using (var uImg = img.Lock()) { bmp = toBitmap(uImg, PixelFormat.Format32bppArgb); } return(bmp); }
/// <summary> /// Converts the specified managed array to the corresponding bitmap source. /// </summary> /// <param name="image">Managed array.</param> /// <returns>Bitmap source.</returns> public static BitmapSource ToBitmapSource(this Bgra <byte>[,] image) { BitmapSource bmpSource = null; using (var uImg = image.Lock()) { bmpSource = BitmapSource.Create(uImg.Width, uImg.Height, 96, 96, PixelFormats.Bgr32, null, uImg.ImageData, uImg.Stride * uImg.Height, uImg.Stride); } return(bmpSource); }
/// <summary> /// Saves the specified image. /// </summary> /// <param name="image">Image to save.</param> /// <param name="fileName">Image filename.</param> public static void Save(this Bgra <double>[,] image, string fileName) { image.Save <Bgra <double> >(fileName); }
/// <summary> /// Converts 8-bit Bgra to 8-bit Bgr color. /// </summary> /// <param name="bgra">Source color.</param> /// <param name="bgr">Destination color.</param> public static void Convert(Bgra <byte> bgra, ref Bgr <byte> bgr) { bgr.B = bgra.B; bgr.G = bgra.G; bgr.R = bgra.R; }
/// <summary> /// Converts the source color to the destination color. /// </summary> /// <param name="image">Source image.</param> /// <returns>Image with converted color.</returns> public static Bgr <byte>[,] ToBgr(this Bgra <byte>[,] image) { return(image.Convert <Bgra <byte>, Bgr <byte> >(Bgra <byte> .Convert)); }
/// <summary> /// Converts the source color to the destination color. /// </summary> /// <param name="image">Source image.</param> /// <param name="area">Working area.</param> /// <returns>Image with converted color.</returns> public static Bgr <byte>[,] ToBgr(this Bgra <byte>[,] image, Rectangle area) { return(image.Convert <Bgra <byte>, Bgr <byte> >(Bgra <byte> .Convert, area)); }
public static CvScalar ToCvScalar(this Bgra <byte> color) { return(new CvScalar { V0 = color.B, V1 = color.G, V2 = color.R, V3 = color.A }); }
/// <summary> /// Encodes the specified image into the specified image type byte array. /// </summary> /// <param name="image">Image to encode.</param> /// <param name="extension">Image type extension (.bmp, .png, .jpg)</param> /// <returns>Image type byte array.</returns> public static byte[] Encode(this Bgra <ushort>[,] image, string extension) { return(encode(image, extension, null)); }
/// <summary> /// Converts the source channel depth to the destination channel depth. /// </summary> /// <typeparam name="TDepth">Destination channel depth.</typeparam> /// <param name="image">Image.</param> /// <returns>Image with converted element depth.</returns> public static Bgra <TDepth>[,] Cast <TDepth>(this Bgra <double>[,] image) where TDepth : struct { return(image.ConvertChannelDepth <Bgra <double>, Bgra <TDepth> >()); }
/// <summary> /// Converts the source color to the destination color. /// </summary> /// <param name="image">Source image.</param> /// <returns>Image with converted color.</returns> public static Gray <byte>[,] ToGray(this Bgra <byte>[,] image) { return(image.Convert <Bgra <byte>, Gray <byte> >(Bgra <byte> .Convert)); }
/// <summary> /// Saves the specified image. /// </summary> /// <param name="image">Image to save.</param> /// <param name="fileName">Image filename.</param> public static void Save(this Bgra <ushort>[,] image, string fileName) { image.Save <Bgra <ushort> >(fileName); }
/// <summary> /// Converts the source color to the destination color. /// </summary> /// <param name="image">Source image.</param> /// <param name="area">Working area.</param> /// <returns>Image with converted color.</returns> public static Gray <byte>[,] ToGray(this Bgra <byte>[,] image, Rectangle area) { return(image.Convert <Bgra <byte>, Gray <byte> >(Bgra <byte> .Convert, area)); }
/// <summary> /// Gets System.Drawing.Color from Bgra8 color. /// </summary> /// <param name="color">Color.</param> /// <returns>System.Drawing.Color</returns> public static System.Drawing.Color ToColor(this Bgra <byte> color) { return(Color.FromArgb(color.A, color.R, color.G, color.B)); }
/// <summary> /// Encodes the specified image into the PNG byte array. /// </summary> /// <param name="image">Image to encode.</param> /// <param name="pngCompression">PNG compression level [0..9] where 9 is the highest compression.</param> /// <returns>PNG byte array.</returns> public static byte[] EncodeAsPng(this Bgra <ushort>[,] image, int pngCompression = 3) { return(encodeAsPng(image, pngCompression)); }