コード例 #1
0
        public static Image LoadFromFile(string filepath)
        {
            var image = new MagickImage(filepath);
            IPixelCollection <byte> pixelCollection = image.GetPixels();
            ImageUInt8RGB           result          = new ImageUInt8RGB((uint)image.Width, (uint)image.Height);

            for (int x = 0; x < image.Width; x++)
            {
                for (int y = 0; y < image.Height; y++)
                {
                    IPixel <byte> pixel = pixelCollection.GetPixel(x, y);
                    result.R[x, y] = pixel.GetChannel(0);
                    result.G[x, y] = pixel.GetChannel(1);
                    result.B[x, y] = pixel.GetChannel(2);
                }
            }
            return(result);
        }