BioCore  5.0.0
A Windows .NET microscopy library and application for viewing, editing, and annotating images.
Loading...
Searching...
No Matches
ImageView.Rgb.cs
Go to the documentation of this file.
1using System.Drawing.Imaging;
2using System.Runtime.InteropServices;
3
4namespace BioCore
5{
6 public partial class ImageView
7 {
8 private static void MaskRgbComponents(System.Drawing.Bitmap image, bool[] enabled)
9 {
10 if (enabled.All(value => value)) return;
11 var data = image.LockBits(new System.Drawing.Rectangle(0, 0, image.Width, image.Height),
12 ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
13 try
14 {
15 var row = new byte[image.Width * 4];
16 for (int y = 0; y < image.Height; y++)
17 {
18 IntPtr address = IntPtr.Add(data.Scan0, y * data.Stride);
19 Marshal.Copy(address, row, 0, row.Length);
20 for (int x = 0; x < row.Length; x += 4)
21 {
22 if (!enabled[0]) row[x + 2] = 0;
23 if (!enabled[1]) row[x + 1] = 0;
24 if (!enabled[2]) row[x] = 0;
25 }
26 Marshal.Copy(row, 0, address, row.Length);
27 }
28 }
29 finally { image.UnlockBits(data); }
30 }
31 }
32}
OpenTK.Graphics.OpenGL.PixelFormat PixelFormat
Definition SlideGLArea.cs:8