I’m trying to access pixel colors from Bulkdata. Already in package build, it needs to be loaded from disk using CreateStreamingRequest(), unlike the editor method. But also the way that the buffer is structured seems to be different. The method below returns the correct color but with an offet along the X axis. For example if I enter the coordinates of point (4500, 1000), it’ll return the colors of (4700,1000). I don’t understand why. The texture format is B8G8R8A8.
FTexture2DMipMap& MipsMap = Texture->GetPlatformData()->Mips[0];
FByteBulkData* RawImageData = &MipsMap.BulkData;
IBulkDataIORequest* Request = RawImageData->CreateStreamingRequest(EAsyncIOPriorityAndFlags::AIOP_Precache, &FBulkDataIORequestCallBack, nullptr);
Request->WaitCompletion();
if (Request->PollCompletion())
{
uint8* RawByteArray = Request->GetReadResults();
int32 TextureWidth = 8671;
int32 TextureHeight = 4081;
const int32 PixelStride = 4;
FColor ByteColor;
int32 Offset = (Y * TextureWidth + X) * PixelStride;
ByteColor.B = RawByteArray[Offset + 0];
ByteColor.G = RawByteArray[Offset + 1];
ByteColor.R = RawByteArray[Offset + 2];
ByteColor.A = RawByteArray[Offset + 3];
PixelColor = ByteColor;
}