For backwards compatibility, we are not going to use a colorspace when decoding with SKBitmap.Decode(...)
This commit is contained in:
Родитель
59139457ae
Коммит
42a1a4abe8
|
@ -414,6 +414,8 @@ namespace SkiaSharp
|
|||
if (info.AlphaType == SKAlphaType.Unpremul) {
|
||||
info.AlphaType = SKAlphaType.Premul;
|
||||
}
|
||||
// for backwards compatibility, remove the colorspace
|
||||
info.ColorSpace = null;
|
||||
return Decode (codec, info);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,27 @@ namespace SkiaSharp.Tests
|
|||
Assert.AreEqual(new SKPointI(-7, -7), offset);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBitmapDecodeDrawsCorrectly()
|
||||
{
|
||||
var path = Path.Combine(PathToImages, "color-wheel.png");
|
||||
|
||||
using (var bitmap = SKBitmap.Decode(path))
|
||||
using (var surface = SKSurface.Create(new SKImageInfo(200, 200))) {
|
||||
var canvas = surface.Canvas;
|
||||
canvas.Clear(SKColors.White);
|
||||
canvas.DrawBitmap(bitmap, 0, 0);
|
||||
|
||||
using (var img = surface.Snapshot())
|
||||
using (var bmp = SKBitmap.FromImage(img)) {
|
||||
Assert.AreEqual(new SKColor(2, 255, 42), bmp.GetPixel(20, 20));
|
||||
Assert.AreEqual(new SKColor(1, 83, 255), bmp.GetPixel(108, 20));
|
||||
Assert.AreEqual(new SKColor(255, 166, 1), bmp.GetPixel(20, 108));
|
||||
Assert.AreEqual(new SKColor(255, 1, 214), bmp.GetPixel(108, 108));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BitmapAndPixmapAreValid()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче