public static Texture2D Pixelize(Texture2D texture, Vector2i pixels, PixelizeFunction function)
        {
            Ensure.False(pixels.X < 0 || pixels.Y < 0 || texture.Width < pixels.X || texture.Height < pixels.Y);

            if (texture.Width == pixels.X && texture.Height == pixels.Y)
            {
                return texture;
            }

            Color[] pixelDataSource = texture.GetData<Color>();
            Color[] pixelDataOutput;

            if (function == PixelizeFunction.Average)
            {
                GraphicsHelper.PixelizeAverage(texture, pixelDataSource, pixels, out pixelDataOutput);
            }
            else if (function == PixelizeFunction.Center)
            {
                GraphicsHelper.PixelizeCenter(texture, pixelDataSource, pixels, out pixelDataOutput);
            }
            else
            {
                throw new ArgumentException("function");
            }

            Texture2D result = new Texture2D(texture.GraphicsDevice, texture.Width, texture.Height);
            result.SetData(pixelDataOutput);

            return result;
        }
        // These would be a lot faster to do in GPU
        #region Pixelize

        // Doesn't actually downscale. Downscaling could be faster
        public static Texture2D Pixelize(Texture2D texture, int pixelSize, PixelizeFunction function)
        {
            return GraphicsHelper.Pixelize(texture, new Vector2i(texture.Width / pixelSize, texture.Height / pixelSize), function);
        }