Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font's returned as garbage #24

Closed
dmitsuki opened this issue Jun 15, 2017 · 2 comments
Closed

Font's returned as garbage #24

dmitsuki opened this issue Jun 15, 2017 · 2 comments

Comments

@dmitsuki
Copy link

dmitsuki commented Jun 15, 2017

I'm not getting back the default font correctly. I'm receiving it as garbage. Only portions of the first two lines are read, and nothing else is returned properly

IO io = ImGui.GetIO();

        FontTextureData textureData = io.FontAtlas.GetTexDataAsRGBA32();

int[] pixels = new int[textureData.Width * textureData.Height];
int count = 0;
for (int i = 0; i < textureData.Height; i++)
{
for (int j = 0; j < textureData.Width; j++)
{

                pixels[i + j] = *((uint* )textureData.Pixels + count);
                count += textureData.BytesPerPixel; 
            }
        }

Is an example of how I'm getting the data. It seems to read the only the first two lines, then it returns transparent pixels for the rest.

If I load the font texture myself (as a png I took from the native imgui) everything works fine.

@mellinoe
Copy link
Collaborator

mellinoe commented Jun 15, 2017 via email

@dmitsuki
Copy link
Author

DOH!

I have been staring at this for so long my brain was automatically turning "i+j" into the definition of a multidimensional array or something, but the computer correctly assumes it's just arithmetic.

I'm somewhat curious as to how the first two lines always came out correctly but that's enough of that for now. Sorry for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants