Esempio n. 1
0
        static Tuple <int, int, int> BestLight(SimpleBitmap pic, int area)
        {
            int bestX = 0;
            int bestY = 0;
            int bestV = 0;

            for (int y = 0; y < pic.height - area; y++)
            {
                for (int x = 0; x < pic.width - area; x++)
                {
                    int v = 0;
                    for (int cy = 0; cy < area; cy++)
                    {
                        for (int cx = 0; cx < area; cx++)
                        {
                            int pix = pic.pixel[x + cx + (y + cy) * pic.width];
                            v += pix & 0xff;
                            v += (pix >> 8) & 0xff;
                            v += (pix >> 16) & 0xff;
                        }
                    }
                    if (v > bestV)
                    {
                        bestX = x;
                        bestY = y;
                        bestV = v;
                    }
                }
            }
            return(new Tuple <int, int, int>(bestX + area / 2, bestY + area / 2, bestV));
        }
Esempio n. 2
0
        /// <summary>
        /// Testmethode zum auslesen der Helligkeit in Fotos
        /// </summary>
        static void TestBright()
        {
            foreach (var file in new DirectoryInfo(TestPhotos + "\\Blue").GetFiles("*.JPG"))
            {
                Console.Write("{0} ({1:N1} kByte) ", file.Name, file.Length / 1024.0);
                var pic = Image.FromFile(file.FullName);

                var simple = new SimpleBitmap(pic);

                var light = BestLight2(simple, 350);

                Console.WriteLine("{0} x {1} - val: {2:N0}", light.Item1, light.Item2, light.Item3);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// erstellt ein neues Simplebitmap anhand eines vorhandenen Bildes
 /// </summary>
 /// <param name="image">Bild, welches ausgelesen werden soll</param>
 /// <returns>fertig erstelltes SimpleBitmap</returns>
 public static SimpleBitmap ToSimpleBitmap(this Image image)
 {
     return(SimpleBitmap.FromImage(image));
 }