示例#1
0
        public void updateBoard()
        {
            DirectoryInfo d = new DirectoryInfo(@"C:\Users\xxins\Pictures\bitmapAnimation\fire");

            FileInfo[] filenames = d.GetFiles("*.jpg");


            foreach (FileInfo file in filenames)
            {
                string      filename = file.FullName;
                Bitmap      image1   = new Bitmap(@filename, true);
                picCompress p        = new picCompress();
                image1 = p.compress(image1);
                for (int x = 0; x < image1.Width; x++)
                {
                    for (int y = 0; y < image1.Height; y++)
                    {
                        Color pixel = image1.GetPixel(y, x);
                        //Console.WriteLine(pixel.GetBrightness());
                        if (pixel.Name == "ff000000" || pixel.R <= blackThreashold && pixel.G <= blackThreashold && pixel.B <= blackThreashold)
                        {
                            matrix[y, x] = "-1 ";
                        }
                        else if (pixel.Name == "ffffffff" || pixel.GetBrightness() > 0.8)
                        {
                            matrix[y, x] = "-2 ";
                        }
                        else if (pixel.R >= pixel.G - whiteThreashold && pixel.R <= pixel.G + whiteThreashold &&
                                 pixel.G >= pixel.B - whiteThreashold && pixel.G <= pixel.B + whiteThreashold &&
                                 pixel.B >= pixel.R - whiteThreashold && pixel.B <= pixel.R + whiteThreashold)
                        {
                            matrix[y, x] = "-3 ";
                        }
                        else
                        {
                            matrix[y, x] = (int)(pixel.GetHue() / 1.41176470588) + " ";
                        }
                    }
                }
                //for (int x = 0; x < image1.Width; x++)
                //{
                //    for (int y = 0; y < image1.Height; y++)
                //    {
                //        Console.Write(matrix[y, x]);
                //    }
                //    Console.Write("\n");
                //}
                sendData();
                System.Threading.Thread.Sleep(animationDelay);
            }
        }
示例#2
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            Bitmap Newbmp;

            string filename           = "tempURLpic.bmp";
            DownloadRemoteImageFile d = new DownloadRemoteImageFile(picURL, filename);

            Image       URLpic = new Bitmap(filename);
            picCompress Comp   = new picCompress();

            Newbmp = Comp.compress(URLpic);

            currentImage        = Newbmp;
            bitmapDisplay.Image = currentImage;
        }
示例#3
0
        private void button2_Click(object sender, EventArgs e)
        {
            //change the current bmp selected
            openFileDialog1.Filter           = "Image files |*.bmp;*.gif;*.jpg;*.jpeg;*.jpe;*.jfif;*.tif;*.tiff;|PNG (not-recommended) (*.png)|*.png|All Files (*.*)|*.*";
            openFileDialog1.InitialDirectory = @"C:\Users\" + Environment.UserName + "\\Pictures";
            openFileDialog1.Title            = "Please select an image file to use";
            openFileDialog1.FileName         = "";
            DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.



            string file = openFileDialog1.FileName;

            Console.WriteLine(file);

            if (file == "")
            {
                return;
            }
            Image choosenImage = new Bitmap(@file);

            if (result == DialogResult.OK) // Test result.
            {
                if (choosenImage.Height != 20 || choosenImage.Width != 20)
                {
                    Bitmap      Newbmp;
                    picCompress Comp = new picCompress();

                    Newbmp = Comp.compress(choosenImage);

                    currentImage        = Newbmp;
                    bitmapDisplay.Image = currentImage;
                }
                else
                {
                    currentImage        = choosenImage;
                    bitmapDisplay.Image = currentImage;
                }
            }
        }