private void btnPrintPreview_Click(object sender, RoutedEventArgs e)
        {
            Screen screen = (Screen)cmbxScreenList.SelectedItem;

            Bitmap bmp = new Bitmap(txtbPreviewPath.Text);

            Point[] points = GraphicHelper.ComputeTargetPoints(new Size(800, 601), new Size(bmp.Width, bmp.Height), Rotation.DEG_0);

            Bitmap bmpResized = new Bitmap(800, 601);

            using (Graphics gr = Graphics.FromImage(bmpResized))
            {
                gr.DrawImage(bmp, points);
            }

            grayData = GrayScaleConverter.ConvertToGrayscale(bmpResized, GrayScaleConverter.ConvertionMethod.AverageBT601, 8);

            grayData = GrayScaleConverter.DitherSierraLight(grayData, 8, bmpResized.Width, bmpResized.Height);

            grayData = GrayScaleConverter.ReverseGrayScale(grayData, 8);

            grayData = GrayScaleConverter.CompactArray(grayData, 8);

            screen.SendImageBuffer(8, grayData);

            screen.DrawBuffer();
        }
        private async void BtnEcho_OnClick(object sender, RoutedEventArgs e)
        {
            Bitmap bmp = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mlp.jpg"));

            Bitmap newImage = new Bitmap(800, 601);

            using (Graphics gr = Graphics.FromImage(newImage))
            {
                gr.SmoothingMode     = SmoothingMode.HighQuality;
                gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
                gr.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                gr.DrawImage(bmp, new Rectangle(0, 0, 800, 601));

                gr.Save();
            }

            byte[] grayData = GrayScaleConverter.FromBitmap(newImage, GrayScaleConverter.ConvertionMethod.Desaturation, GrayScaleConverter.DitheringMethod.Atkinson, false, 8);

            grayData = GrayScaleConverter.ReverseGrayScale(grayData, 8);

            //await Connector.testImage("", grayData);
        }
        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);
        }