public void ScaleImage(int scaleSize, int[] src, int[] trg, int srcWidth, int srcHeight, ScalerCfg cfg, int yFirst, int yLast)
 {
     _scaler         = scaleSize.ToIScaler();
     _cfg            = cfg;
     _colorDistance  = new ColorDist(_cfg);
     _colorEqualizer = new ColorEq(_cfg);
     ScaleImageImpl(src, trg, srcWidth, srcHeight, yFirst, yLast);
 }
예제 #2
0
        // scaleSize = 2 to 5
        public Bitmap ScaleImage(Bitmap image, int scaleSize, ScalerCfg config = null)
        {
            config = config ?? new ScalerCfg();

            var fixedFormatImage = image.ChangeFormat(PixelFormat.Format32bppRgb);
            var rgbValues        = fixedFormatImage.ToIntArray();

            var scaleFactor     = scaleSize;
            var scaledRbgValues = new int[rgbValues.Length * (scaleFactor * scaleFactor)];

            ScaleImage(scaleSize, rgbValues, scaledRbgValues, fixedFormatImage.Width, fixedFormatImage.Height, config, 0, int.MaxValue);

            return(scaledRbgValues.ToBitmap(fixedFormatImage.Width * scaleFactor, fixedFormatImage.Height * scaleFactor, fixedFormatImage.PixelFormat));
        }
        public Color32[] ScaleImage(Texture2D texture, int scaleSize, ScalerCfg config = null)
        {
            byte[] bytes = ImageConversion.EncodeToPNG(texture);

            System.IO.Stream s = new System.IO.MemoryStream(bytes);

            Bitmap bitmap = new Bitmap(s);

            Bitmap result = ScaleImage(bitmap, scaleSize, config);

            Color32[] colors = new Color32[result.Width * result.Height];
            for (int y = 0; y < result.Height; y++)
            {
                for (int x = 0; x < result.Width; x++)
                {
                    System.Drawing.Color c = result.GetPixel(x, y);
                    colors[(result.Height - y - 1) * result.Width + x] = new Color32(c.R, c.G, c.B, c.A);
                }
            }
            return(colors);
        }