mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 05:58:35 +01:00
Premultiply textures when using RawContentManager
This commit is contained in:
parent
16b9e26969
commit
47b58b1942
3 changed files with 20 additions and 1 deletions
|
@ -40,6 +40,10 @@ Removals
|
||||||
- Marked old Draw and DrawTransformed overloads as obsolete in favor of SpriteBatchContext ones
|
- Marked old Draw and DrawTransformed overloads as obsolete in favor of SpriteBatchContext ones
|
||||||
- Marked Tooltip.Paragraph as obsolete in favor of new Paragraphs collection
|
- Marked Tooltip.Paragraph as obsolete in favor of new Paragraphs collection
|
||||||
|
|
||||||
|
### MLEM.Data
|
||||||
|
Improvements
|
||||||
|
- Premultiply textures when using RawContentManager
|
||||||
|
|
||||||
## 5.3.0
|
## 5.3.0
|
||||||
### MLEM
|
### MLEM
|
||||||
Additions
|
Additions
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using MLEM.Extensions;
|
||||||
|
|
||||||
namespace MLEM.Data.Content {
|
namespace MLEM.Data.Content {
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -11,7 +13,20 @@ namespace MLEM.Data.Content {
|
||||||
existing.Reload(stream);
|
existing.Reload(stream);
|
||||||
return existing;
|
return existing;
|
||||||
} else {
|
} else {
|
||||||
return Texture2D.FromStream(manager.GraphicsDevice, stream);
|
// premultiply the texture's color to be in line with the pipeline's texture reader
|
||||||
|
// TODO this can be converted to use https://github.com/MonoGame/MonoGame/pull/7369 in the future
|
||||||
|
using (var texture = Texture2D.FromStream(manager.GraphicsDevice, stream)) {
|
||||||
|
var ret = new Texture2D(manager.GraphicsDevice, texture.Width, texture.Height);
|
||||||
|
using (var textureData = texture.GetTextureData()) {
|
||||||
|
using (var retData = ret.GetTextureData()) {
|
||||||
|
for (var x = 0; x < ret.Width; x++) {
|
||||||
|
for (var y = 0; y < ret.Height; y++)
|
||||||
|
retData[x, y] = Color.FromNonPremultiplied(textureData[x, y].ToVector4());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 896 B After Width: | Height: | Size: 899 B |
Loading…
Reference in a new issue