Issue reading pixel values of HDR UTexture2D

I’ve been working with using images as heightmaps, by reading individual pixel values of the UTexture2D object and creating a procedural mesh based on that. However, I’ve hit a limitation, as a regular image with 8-bits per-channel cannot hold precise enough values to create a proper landscape. So I’m trying to work with HDR images, and I’ve created a few HDR images and set their compression mode to HDR (RGB, no sRGB).

However, I can’t figure out how to modify my code to properly read the data when it’s compressed with this method.

This is the function I was using to read the data before:

void AProceduralActor::ParseUTexture2DToFColorArray(UTexture2D * HeightMap, TArray<FColor> &ColorArray, FIntVector2D &WidthHeight) {
	ColorArray.Empty();
	FTexture2DMipMap* HeightMipMap = &HeightMap->PlatformData->Mips[0];
	FByteBulkData* RawImageData = &HeightMipMap->BulkData;
	FColor* FormattedImageData = static_cast<FColor*>(RawImageData->Lock(LOCK_READ_ONLY));

	WidthHeight.X = HeightMipMap->SizeX;
	WidthHeight.Y = HeightMipMap->SizeY;

	const int32 TotalTextureSize = WidthHeight.X * WidthHeight.Y;
	auto stride = (int32)(sizeof(int8) * 4);
	ColorArray.SetNumUninitialized(TotalTextureSize);
	FMemory::Memcpy(ColorArray.GetData(), FormattedImageData, TotalTextureSize * stride);
	RawImageData->Unlock();
}

I thought that I might be able to use an FLinearColor pointer instead of FColor, and then change the stride so that the correct memory would be copied, but I still seem to get incorrect values for pixels. My ultimate goal is to populate a TArray with FLinearColors with the values from the texture, to use as values for vertex locations.