diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-09-03 19:40:05 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-09-03 19:40:05 -0400 |
commit | af6c273d8aaf4199741aaecab6bd4e95754dce49 (patch) | |
tree | 09978300f43a13e6a4d3168b34c0c73492b57afa /src/SMAPI/Framework/ContentManagers/ModContentManager.cs | |
parent | 047091a1a400ec426eab36cfa94d11a8e917800c (diff) | |
download | SMAPI-af6c273d8aaf4199741aaecab6bd4e95754dce49.tar.gz SMAPI-af6c273d8aaf4199741aaecab6bd4e95754dce49.tar.bz2 SMAPI-af6c273d8aaf4199741aaecab6bd4e95754dce49.zip |
fix transparency issues on Linux/Mac due to MonoGame bug (#279)
Diffstat (limited to 'src/SMAPI/Framework/ContentManagers/ModContentManager.cs')
-rw-r--r-- | src/SMAPI/Framework/ContentManagers/ModContentManager.cs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs index 7048dcf3..ed76a925 100644 --- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs @@ -171,6 +171,14 @@ namespace StardewModdingAPI.Framework.ContentManagers /// <remarks>Based on <a href="https://gamedev.stackexchange.com/a/26037">code by David Gouveia</a>.</remarks> private Texture2D PremultiplyTransparency(Texture2D texture) { + // Textures loaded by Texture2D.FromStream are already premultiplied on Linux/Mac, even + // though the XNA documentation explicitly says otherwise. That's a glitch in MonoGame + // fixed in newer versions, but the game uses a bundled version that will always be + // affected. See https://github.com/MonoGame/MonoGame/issues/4820 for more info. + if (Constants.TargetPlatform != GamePlatform.Windows) + return texture; + + // premultiply pixels Color[] data = new Color[texture.Width * texture.Height]; texture.GetData(data); for (int i = 0; i < data.Length; i++) |