Ejemplo n.º 1
0
 private static void DitherCalculateAndSave(DitheringBase method, Bitmap input, string filenameWithoutExtension)
 {
     Bitmap dithered = method.DoDithering(input);
     double mse = CalculateMSE(input, dithered);
     double psrn = CalculatePSRN(mse);
     Console.WriteLine("Method: " + method.GetMethodName() + " PSRN: " + psrn);
     dithered.Save(filenameWithoutExtension + method.GetFilenameAddition() + ".png");
 }
Ejemplo n.º 2
0
        private static void DitherCalculateAndSave(DitheringBase method, Bitmap input, string filenameWithoutExtension)
        {
            Bitmap dithered = method.DoDithering(input);
            double mse      = CalculateMSE(input, dithered);
            double psrn     = CalculatePSRN(mse);

            Console.WriteLine("Method: " + method.GetMethodName() + " PSRN: " + psrn);
            dithered.Save(filenameWithoutExtension + method.GetFilenameAddition() + ".png");
        }
Ejemplo n.º 3
0
        public static void DitherAndWritePngStream(Stream outputStream, Bitmap bitmap, DitheringBase <byte> ditherer, bool writeToSameBitmap = true)
        {
            byte[] bytes = ReadWriteBitmaps.ReadBitmapToColorBytes(bitmap);

            TempByteImageFormat temp = new TempByteImageFormat(bytes, bitmap.Width, bitmap.Height, 3);

            temp = (TempByteImageFormat)ditherer.DoDithering(temp);

            if (writeToSameBitmap)
            {
                ReadWriteBitmaps.WriteToBitmap(bitmap, temp.GetPixelChannels);
                bitmap.Save(outputStream, System.Drawing.Imaging.ImageFormat.Png);
            }
            else
            {
                Bitmap tempBitmap = new Bitmap(bitmap.Width, bitmap.Height, bitmap.PixelFormat);
                ReadWriteBitmaps.WriteToBitmap(tempBitmap, temp.GetPixelChannels);
                tempBitmap.Save(outputStream, System.Drawing.Imaging.ImageFormat.Png);
            }
        }
Ejemplo n.º 4
0
 private static DitheringBase <byte> GetDitherer(DitheringMethod method, DitheringBase <byte> .ColorFunction colorfunc) =>
 method switch
 {
Ejemplo n.º 5
0
        public static Bitmap DitherCalculate(DitheringBase method, Bitmap input)
        {
            Bitmap dithered = method.DoDithering(input);

            return(dithered);
        }
Ejemplo n.º 6
0
        private static (long checksum, int colorCount) DoDitheringAndGetChecksumAndColorCount(DitheringBase <byte> dithering, Bitmap bitmap)
        {
            using (var image = bitmap)
            {
                byte[,,] bytes = ReadTo3DBytes(image);

                TempByteImageFormat temp = new TempByteImageFormat(bytes);
                dithering.DoDithering(temp);

                WriteToBitmap(image, temp.GetPixelChannels);
                //image.Save("temp123.png");

                return(GetImageTotalPixelSum(image), CountTotalColors(image));
            }
        }