private void ScreenWriteBufferGrayScale()
        {
            Bitmap bmp = GrayScaleConverter.GrayToBitmap(DisplayedScreenBuffer, ScreenConnection.Screen.Width, ScreenConnection.Screen.Height, DisplayedGrayScaleDepth);

            this.Dispatcher.Invoke((Action)(() =>
            {
                imgScreenDispalyed.Source = BitmapToImageSource(bmp);
            }));
        }
예제 #2
0
        private void BTN_GenAll_Click(object sender, EventArgs e)
        {
            Bitmap bmp = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LSTB_Files.SelectedItem.ToString()));

            int count = 1;

            if (!Directory.Exists(@".\out\"))
            {
                Directory.CreateDirectory(@".\out\");
            }

            foreach (int grayScale in new List <int>()
            {
                2, 4, 8, 16, 32, 64, 128, 256
            })
            {
                foreach (GrayScaleConverter.ConvertionMethod convValue in Enum.GetValues(typeof(GrayScaleConverter.ConvertionMethod)))
                {
                    foreach (GrayScaleConverter.DitheringMethod ditherValue in Enum.GetValues(typeof(GrayScaleConverter.DitheringMethod)))
                    {
                        foreach (bool serpentine in new List <bool>()
                        {
                            false, true
                        })
                        {
                            byte[] grayData = GrayScaleConverter.FromBitmap(bmp, convValue, ditherValue, serpentine, grayScale);

                            Bitmap grayBmp = GrayScaleConverter.GrayToBitmap(grayData, bmp.Width, bmp.Height, grayScale);

                            string convName   = Enum.GetName(typeof(GrayScaleConverter.ConvertionMethod), convValue);
                            string ditherName = Enum.GetName(typeof(GrayScaleConverter.DitheringMethod), ditherValue);

                            string strCount = count.ToString().PadLeft(3, '0');

                            grayBmp.Save(@".\out\" + LSTB_Files.SelectedItem.ToString() + "-" + strCount
                                         + "-" + grayScale
                                         + "-" + convName
                                         + "-" + ditherName
                                         + "-" + (serpentine ? "Serp" : "Regular")
                                         + ".png", ImageFormat.Png);

                            count++;
                        }
                    }
                }
            }
        }
예제 #3
0
        private void render()
        {
            if (LSTB_Files.SelectedItem == null || String.IsNullOrWhiteSpace(LSTB_Files.SelectedItem.ToString()))
            {
                return;
            }

            Bitmap bmp = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LSTB_Files.SelectedItem.ToString()));

            int depth = int.Parse(CMBX_GrayScale.SelectedItem.ToString());

            GrayScaleConverter.ConvertionMethod method    = (GrayScaleConverter.ConvertionMethod)Enum.Parse(typeof(GrayScaleConverter.ConvertionMethod), CMBX_Method.SelectedItem.ToString());
            GrayScaleConverter.DitheringMethod  dithering = (GrayScaleConverter.DitheringMethod)Enum.Parse(typeof(GrayScaleConverter.DitheringMethod), CMBX_Dithering.SelectedItem.ToString());
            bool serpentine = CHKB_Serpentine.Checked;


            byte[] grayData = GrayScaleConverter.FromBitmap(bmp, method, dithering, serpentine, depth);

            Bitmap grayBmp = GrayScaleConverter.GrayToBitmap(grayData, bmp.Width, bmp.Height, depth);

            PCBX_Output.Image = grayBmp;
        }
예제 #4
0
        private void loadImage(string path)
        {
            //Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mlp.png")
            Bitmap bmp = new Bitmap(path);

            Bitmap bmpResized = new Bitmap(bmp, 800, 601);


            int depth = 8;

            GrayScaleConverter.ConvertionMethod method    = GrayScaleConverter.ConvertionMethod.DecompositionMax;
            GrayScaleConverter.DitheringMethod  dithering = GrayScaleConverter.DitheringMethod.Atkinson;
            bool serpentine = false;


            grayData = GrayScaleConverter.FromBitmap(bmpResized, method, dithering, serpentine, depth);

            Bitmap grayBmp = GrayScaleConverter.GrayToBitmap(grayData, bmpResized.Width, bmpResized.Height, depth);

            grayData = GrayScaleConverter.ReverseGrayScale(grayData, depth);

            imgPreview.Source = bitmapToImageSource(grayBmp);
        }