improve premultiplication performance
This commit is contained in:
parent
868eefb9a7
commit
8036bcdf00
|
@ -7,6 +7,7 @@
|
|||
* MacOS files starting with `._` are now ignored and can no longer cause skipped mods.
|
||||
* Simplified paranoid warning logs and reduced their log level.
|
||||
* Reduced startup time when loading mod DLLs (thanks to ZaneYork!).
|
||||
* Reduced processing time when a mod loads many unpacked images (thanks to Entoarox!).
|
||||
* Fixed `BadImageFormatException` error detection.
|
||||
* Fixed black maps on Android for mods which use `.tmx` files.
|
||||
|
||||
|
|
|
@ -246,10 +246,11 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
|||
texture.GetData(data);
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (data[i].A == byte.MinValue || data[i].A == byte.MaxValue)
|
||||
var pixel = data[i];
|
||||
if (pixel.A == byte.MinValue || pixel.A == byte.MaxValue)
|
||||
continue; // no need to change fully transparent/opaque pixels
|
||||
|
||||
data[i] = Color.FromNonPremultiplied(data[i].ToVector4());
|
||||
data[i] = new Color(pixel.R * pixel.A / byte.MaxValue, pixel.G * pixel.A / byte.MaxValue, pixel.B * pixel.A / byte.MaxValue, pixel.A); // slower version: Color.FromNonPremultiplied(data[i].ToVector4())
|
||||
}
|
||||
|
||||
texture.SetData(data);
|
||||
|
|
Loading…
Reference in New Issue