Skip to content

Conversion from RgbaVector Incorrect #2048

@PeteMichaud

Description

@PeteMichaud

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

2.0.0

Other ImageSharp packages and versions

none

Environment (Operating system, version and so on)

win10 pro (Version 10.0.19043 Build 19043)

.NET Framework version

4.7.2

Description

I might be misunderstanding what's supposed to happen, but I think this is a bug:

var sourceImg = GetImage<RgbaVector>();

using (var clonedImg = sourceImg.CloneAs<HalfVector4>()) //<- should load the equivalent color values in the new HalfVector4 format?
{
    Rgba32 srcColor = new Rgba32();
    Rgba32 convertedColor = new Rgba32();

    sourceImg[0, 0].ToRgba32(ref srcColor);
    clonedImg[0, 0].ToRgba32(ref convertedColor);
                    
    Console.WriteLine($"{sourceImg[0, 0]} -> {srcColor}");
    Console.WriteLine($"{clonedImg[0, 0]} -> {convertedColor}");
}

Outputs:

RgbaVector(0.04, 0.04, 0.2, 1) -> Rgba32(10, 10, 51, 255)
HalfVector4(0.04, 0.04, 0.2, 1) -> Rgba32(132, 132, 153, 255)

Am I supposed to manually convert from the 32 bit RgbaVector values to the 16 bit HalfVector4?

Steps to Reproduce

var sourceImg = GetImage<RgbaVector>();

using (var clonedImg = sourceImg.CloneAs<HalfVector4>()) //<- should load the equivalent color values in the new HalfVector4 format?
{
    Rgba32 srcColor = new Rgba32();
    Rgba32 convertedColor = new Rgba32();

    sourceImg[0, 0].ToRgba32(ref srcColor);
    clonedImg[0, 0].ToRgba32(ref convertedColor);
                    
    Console.WriteLine($"{sourceImg[0, 0]} -> {srcColor}");
    Console.WriteLine($"{clonedImg[0, 0]} -> {convertedColor}");
}

Images

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions