# How to read correct pixel values from 32-bit EXR image?

**URL:** <https://forums.unrealengine.com/t/how-to-read-correct-pixel-values-from-32-bit-exr-image/401335>\
**Category:** C++\
**Tags:** hdr, unreal-engine, pixel, question, CPP\
**Created:** [August 8, 2017, 4:16pm UTC](https://forums.unrealengine.com/t/how-to-read-correct-pixel-values-from-32-bit-exr-image/401335 "2017-08-08T16:16:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_07ba773b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_07ba773b](https://forums.unrealengine.com/u/anonymous_user_07ba773b)\
**Post date:** [August 8, 2017, 4:16pm UTC](https://forums.unrealengine.com/t/how-to-read-correct-pixel-values-from-32-bit-exr-image/401335/1 "2017-08-08T16:16:42Z")

</div>

I’m trying to read in pixel values from a 32-bit EXR using the following code:

```
FLinearColor UBlueprintFunctionLibrary::TextureTest(UTexture2D * TextureInput, int32 PixelIndex)
{
	FLinearColor PixelColor;
	PixelColor = FLinearColor(1270, 1270, 1270, 1270);

	if (TextureInput)
	{
		FTexture2DMipMap * CurrentMipMap = &TextureInput->PlatformData->Mips[0];
		FByteBulkData * RawImageData = &CurrentMipMap->BulkData;
		FLinearColor* FormatedImageData = static_cast<FLinearColor*>(RawImageData->Lock(LOCK_READ_ONLY));

		PixelColor = FormatedImageData[PixelIndex];

		TextureInput->PlatformData->Mips[0].BulkData.Unlock();
	}
	return PixelColor;
}

```

Unfortunately, this is giving me completely incorrect values from the pixels.

Does anyone know how to get correct (32-bit / HDR) values from an EXR through C++? Have been bashing my head against this for ages now. I feel like the correct values must be in there, and in theory accessible, but I can’t work out how to get them out.

Any help massively appreciated!

---

<div class="post-metadata">

**Author:** ![Luckylight](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Luckylight](https://forums.unrealengine.com/u/Luckylight)\
**Post date:** [August 13, 2019, 1:25pm UTC](https://forums.unrealengine.com/t/how-to-read-correct-pixel-values-from-32-bit-exr-image/401335/2 "2019-08-13T13:25:09Z")

</div>

Hello.  
Did you solve this issue?

---

<div class="post-metadata">

**Author:** ![somawheels](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@somawheels](https://forums.unrealengine.com/u/somawheels)\
**Post date:** [June 18, 2022, 3:04pm UTC](https://forums.unrealengine.com/t/how-to-read-correct-pixel-values-from-32-bit-exr-image/401335/3 "2022-06-18T15:04:02Z")

</div>

Id like to know this too. I want to render scene depth to a 32bit render target, and read pixels from it.
