I have been trying to get the RGB values of a specific pixel in my texture2D, unfortunately I keeps giving me different values for the same pixel which leads me to believe I did something wrong. I don’t think my pixel rgb should change since it’s the same texture every time, although every time I run my program I reimport the image, but I don’t think that should have an effect because its the exact same image. I change the settings of my Texture2D before I start to find the pixel information but it still returns random colors
FColor UMyFileImporter::GetPixelData(UTexture2D* Texture, int32 X, int32 Y)
{
Texture->MipGenSettings.operator=(TMGS_NoMipmaps);
Texture->SRGB = false;
Texture->CompressionSettings.operator=(TC_VectorDisplacementmap);
FTexture2DMipMap* MyMipMap = &Texture->PlatformData->Mips[0];
FByteBulkData* RawImageData = &MyMipMap->BulkData;
FColor* FormatedImageData = static_cast<FColor*>(RawImageData->Lock(LOCK_READ_ONLY));
uint8 PixelX = X, PixelY = Y;
uint32 TextureWidth = MyMipMap->SizeX, TextureHeight = MyMipMap->SizeY;
FColor PixelColor;
if (PixelX >= 0 && PixelX < TextureWidth && PixelY >= 0 && PixelY < TextureHeight)
{
PixelColor = FormatedImageData[PixelY * TextureWidth + PixelX];
}
RawImageData->Unlock();
return PixelColor;
}