Possible Bug? UTexture2D::CreateTransient

I’m creating a texture here:

SizeX = 64;
SizeY = 64;
textureGraph = UTexture2D::CreateTransient(SizeX, SizeY);

Then I’m running this draw function up in blueprint:

EPixelFormat pixelFormat = textureGraph->PlatformData->PixelFormat;
FTexture2DMipMap* graphMipMap = &textureGraph->PlatformData->Mips[0];

FByteBulkData* rawImageData = &graphMipMap->BulkData;
uint8 * pImageData = (uint8 *)rawImageData->Lock(LOCK_READ_WRITE);

uint32 TextureWidth = SizeX, TextureHeight = SizeY;
FColor PixelColor;
	
PixelColor.R = 0;
PixelColor.G = 0;
PixelColor.B = 0; 
	PixelColor.A = 255;

uint32 DrawLineX = 8;
uint32 DrawLineY = 8;
	
for (uint32 j = 0; j < DrawLineY; j++){
	for (uint32 i = 0; i < DrawLineX; i++){
			uint8 *pPixelAddress = &pImageData[((j * (TextureWidth)) + (i)) * 4];
			pPixelAddress[0] = PixelColor.B;![alt text][1]
			pPixelAddress[1] = PixelColor.G;
			pPixelAddress[2] = PixelColor.R;
			pPixelAddress[3] = PixelColor.A;
	}
}

textureGraph->PlatformData->Mips[0].BulkData.Unlock();
textureGraph->UpdateResource();


return textureGraph;

Just trying to create a small little box for now so I can later make them into a graph or something across the static mesh. Originally I was just changing the whole pixels but by going this far down I was hoping to be able to see what was going on in the memory viewer.

I’ve noticed that when I use blueprint to set this texture to the material on the static mesh it was doubling the amount of pixels it was going in the Y direction, But leaving white space in between and the X direction was being halved. While the whole material seemed to be 16x16 pixels even though I set it as a 64x64. Shown in example 1

After I tried changing:

uint8 *pPixelAddress = &pImageData[((j * (TextureWidth)) + (i)) * 4];

to this:

uint8 *pPixelAddress = &pImageData[((j * (TextureWidth/2)) + (i*2)) * 4];

So changing that I managed to draw a box but it is the wrong colour. And clearly It’s still a 16x16 texture. I’ll go ahead and throw in the images of the blueprint as well.

I’m assuming the problem is coming from the Pixel Format or the Create Transient function. Sorry for bad variable names and for generally having odd formatting before anyone shoots me, I’ve just been trying a lot of different things to test this and it left a lot of trash everywhere and it’s my first time asking a question like this. :slight_smile: