private Image <Rgba32> InternalConvertTexture(IndexedColor256Image inputImage, TextureFormat textureFormat) { var pixels = ImageConversionUtils.ConvertIndexedToRgba32(inputImage, textureFormat); //Alpha tested textures have their fully transparent pixels modified so samplers won't sample the color used and blend it //This stops the color from bleeding through if (textureFormat == TextureFormat.AlphaTest || textureFormat == TextureFormat.IndexAlpha) { ImageConversionUtils.BoxFilter3x3(pixels, inputImage.Width, inputImage.Height); } //Rescale image to nearest power of 2 (var scaledWidth, var scaledHeight) = ComputeScaledSize((uint)inputImage.Width, (uint)inputImage.Height); var scaledPixels = ImageConversionUtils.ResampleImage(new Span <Rgba32>(pixels), inputImage.Width, inputImage.Height, (int)scaledWidth, (int)scaledHeight); return(Image.LoadPixelData(scaledPixels, (int)scaledWidth, (int)scaledHeight)); }
/// <summary> /// Computes the scaled size of a texture that has the given width and height /// </summary> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public (uint, uint) ComputeScaledSize(uint width, uint height) { return(ImageConversionUtils.ComputeScaledSize(width, height, _powerOf2Textures.Value, _maxSize.Value, _roundDown.Value, _picMip.Value)); }
/// <summary> /// Computes the scaled size of a texture that has the given width and height /// </summary> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public (int, int) ComputeScaledSize(int width, int height) { return(ImageConversionUtils.ComputeScaledSize(width, height, _powerOf2Textures.Boolean, _maxSize.Integer, _roundDown.Integer, _picMip.Integer)); }