mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-15 15:44:59 +00:00
feature: supports RGBA16 pixel format
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
203c50350e
commit
d323a2064e
1 changed files with 16 additions and 1 deletions
|
@ -117,6 +117,21 @@ namespace SourceGit.ViewModels
|
|||
case ImageFormat.Rgb24:
|
||||
pixelFormat = PixelFormats.Bgr24;
|
||||
break;
|
||||
case ImageFormat.Rgba16:
|
||||
var pixels2 = pfiImage.DataLen / 2;
|
||||
data = new byte[pixels2 * 4];
|
||||
stride = pfiImage.Width * 4;
|
||||
for (var i = 0; i < pixels2; i++)
|
||||
{
|
||||
var src = BitConverter.ToUInt16(pfiImage.Data, i * 2);
|
||||
data[i * 4 + 0] = (byte)Math.Round((src & 0x0F) / 15F * 255); // B
|
||||
data[i * 4 + 1] = (byte)Math.Round(((src >> 4) & 0x0F) / 15F * 255); // G
|
||||
data[i * 4 + 2] = (byte)Math.Round(((src >> 8) & 0x0F) / 15F * 255); // R
|
||||
data[i * 4 + 3] = (byte)Math.Round(((src >> 12) & 0x0F) / 15F * 255); // A
|
||||
}
|
||||
|
||||
alphaFormat = AlphaFormat.Premul;
|
||||
break;
|
||||
case ImageFormat.Rgba32:
|
||||
alphaFormat = AlphaFormat.Premul;
|
||||
break;
|
||||
|
@ -131,7 +146,7 @@ namespace SourceGit.ViewModels
|
|||
return new ImageSource(bitmap, size);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch
|
||||
{
|
||||
return new ImageSource(null, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue