Exemplo n.º 1
0
        private static SourceImage GetIntensityMap(SourceImage sourceImage, int workerMin, int range)
        {
            var newSourceImage = new SourceImage();

            newSourceImage.Height = sourceImage.Height;
            newSourceImage.Width  = sourceImage.Width;
            newSourceImage.Pixels = new Pixel[newSourceImage.Width * newSourceImage.Height];
            for (int y = 0; y < sourceImage.Height; y++)
            {
                for (int x = 0; x < sourceImage.Width; x++)
                {
                    Color c         = sourceImage.GetPixel(x, y);
                    var   intensity = (int)(c.GetBrightness() * 255);

                    if (intensity >= workerMin && intensity <= workerMin + range)
                    {
                        newSourceImage.SetPixel(x, y, c);
                    }
                    else
                    {
                        newSourceImage.SetPixel(x, y, Color.Black);
                    }
                }
            }

            return(newSourceImage);
        }
Exemplo n.º 2
0
        private bool DrawPixel(Point p, Color c, Graphics g, bool SaveToMap)
        {
            if (IsReady)
            {
                var b = new SolidBrush(c);

                if (p.X >= 0 && p.Y >= 0 && p.X < SourceImage.Width && p.Y < SourceImage.Height)
                {
                    if (SaveToMap)
                    {
                        SourceImage.SetPixel(p.X, p.Y, c);
                    }
                    BitmapGenerate.DrawPixel(SourceImage, g, p.X, p.Y, c);
                    return(true);
                }
            }
            return(false);
        }