# What is the order of FColor\* in MipData obtained from a UTexture2D?

**URL:** <https://forums.unrealengine.com/t/what-is-the-order-of-fcolor-in-mipdata-obtained-from-a-utexture2d/783396>\
**Category:** C++\
**Tags:** mipmap, unreal-engine, CPP, question, texture-channel\
**Created:** [March 4, 2023, 3:27am UTC](https://forums.unrealengine.com/t/what-is-the-order-of-fcolor-in-mipdata-obtained-from-a-utexture2d/783396 "2023-03-04T03:27:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![StellerBap](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/stellerbap/32/549748_2.png) [@StellerBap](https://forums.unrealengine.com/u/StellerBap)\
**Post date:** [March 4, 2023, 3:27am UTC](https://forums.unrealengine.com/t/what-is-the-order-of-fcolor-in-mipdata-obtained-from-a-utexture2d/783396/1 "2023-03-04T03:27:26Z")

</div>

Hello,

I have a quick question about how the FColor pointers are stored when they are derived from a UTexture2D in the following code:

> FTexture2DMipMap\* TexMipMap = &TextureToFillWithRandomColors-\>GetPlatformData()-\>Mips[0];  
> FByteBulkData\* RawImageData = &TexMipMap-\>BulkData;  
> FColor\* MipData = static\_cast\<FColor\*\>( RawImageData-\>Lock(LOCK\_READ\_ONLY ) );

I have no trouble reading or writing to the pixels within the supplied to the function. I just want to know how to traverse the array of FColors.

This code is how I am going through each pixel within the texture.

> if (MipData)  
> {  
> for ( int32 RowNum = 0; RowNum \< TextureWidth; ++RowNum )  
> {  
> for ( int32 ColNum = 0; ColNum \< TextureHeight; ++ColNum )  
> {  
> FColor& CurColor = MipData[( (ColNum\*TextureWidth) + RowNum )];  
> //do something with CurColor  
> }}}

However, I get some unexpected results when trying to do something like make a horizontally striped texture or make a circle. I tried going through the code but couldn’t find an answer to how the pointers are ordered and correspond to the texture asset provided.

Is the first pointer (MipData [0]) in the top left corner? Or, where is the “origin”?  
Do the pointers increment by row or column?

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [March 4, 2023, 3:43am UTC](https://forums.unrealengine.com/t/what-is-the-order-of-fcolor-in-mipdata-obtained-from-a-utexture2d/783396/2 "2023-03-04T03:43:21Z")

</div>

Hi StellerBap,

Yes they are rows of columns, so the for loops are around the correct way (not that it really matters) - just change it to “MipData[(RowNum\*TextureWidth)+ColNum]”

---

<div class="post-metadata">

**Author:** ![StellerBap](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/stellerbap/32/549748_2.png) [@StellerBap](https://forums.unrealengine.com/u/StellerBap)\
**Post date:** [March 5, 2023, 1:41pm UTC](https://forums.unrealengine.com/t/what-is-the-order-of-fcolor-in-mipdata-obtained-from-a-utexture2d/783396/3 "2023-03-05T13:41:39Z")

</div>

Thanks!
