Closed ptasev closed 2 years ago
Hi!
Thanks for the report. I'll take a look today to see if I can spot the issue.
Hmm, it works just fine if I replace destPixel = bgr24
with destPixel.FromScaledVector4(new Vector4(sorcPixel.ToVector3(), 1));
. Since I was casting 256.0+ to byte that resulted in an overflow. Sometimes the RgbFloat value is >1.0 so I have to do the clamping in float first, and then convert to byte last like this:
var vecMax = new Vector3(byte.MaxValue);
var vecHalf = new Vector3(0.5f);
var rgbVal = sorcPixel.ToVector3() * vecMax + vecHalf;
rgbVal = Vector3.Clamp(rgbVal, Vector3.Zero, vecMax);
var bgr24 = new Bgr24((byte)rgbVal.X, (byte)rgbVal.Y, (byte)rgbVal.Z);
The library works just fine, thanks!
Glad you got it working!
I'm converting a decoded BC6h uf16 RgbFloat to Bgr24. Assuming I haven't made a mistake, it appears there may be corruption in the decoder.
Nuget: BcnEncoder.NET ImageSharp 1.1.1 Sample.zip
Here's my code: