WPF를 사용하여 16 비트 PNG 이미지 용 이미지 뷰어를 작성하려고합니다. 내 생각은 PngBitmapDecoder
으로 이미지를로드 한 다음 Image
컨트롤에 넣고 픽셀 쉐이더를 사용하여 밝기/대비를 제어하는 것이 었습니다.HDR (16 비트) 입력이있는 WPF 픽셀 쉐이더?
그러나 픽셀 쉐이더 입력이 이미 8 비트로 변환 된 것으로 보입니다. WPF의 알려진 제한 사항입니까, 아니면 어딘가에서 실수를 했습니까? (Photoshop에서 만든 흑백 그라디언트 이미지로 확인했는데 16 비트 이미지로 확인 됨)
다음은 이미지를로드하는 코드입니다. 전체 16 비트 범위는 그냥 큰 Shazzam shader effect tool와 픽셀 쉐이더를 생성
BitmapSource bitmap;
using (Stream s = File.OpenRead("test.png"))
{
PngBitmapDecoder decoder = new PngBitmapDecoder(s,BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
bitmap = decoder.Frames[0];
}
if (bitmap.Format != PixelFormats.Rgba64)
MessageBox.Show("Pixel format " + bitmap.Format + " is not supported. ");
bitmap.Freeze();
image.Source = bitmap;
) 8 비트로 이미지 컨트롤로드에서 그것을 소스 = "test.png"를 작성.
sampler2D implicitInput : register(s0);
float MinValue : register(c0);
float MaxValue : register(c1);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 color = tex2D(implicitInput, uv);
float t = 1.0f/(MaxValue-MinValue);
float4 result;
result.r = (color.r - MinValue) * t;
result.g = (color.g - MinValue) * t;
result.b = (color.b - MinValue) * t;
result.a = color.a;
return result;
}
그리고는 다음과 같이 XAML에 쉐이더를 통합 :
<Image Name="image" Stretch="Uniform">
<Image.Effect>
<shaders:AutoGenShaderEffect x:Name="MinMaxShader" Minvalue="0.0" Maxvalue="1.0>
</shaders:AutoGenShaderEffect>
</Image.Effect>
</Image>