Skip to content

dimensions of images #301

Answered by paxo-rch
paxo-rch asked this question in Q&A
Oct 26, 2022 · 3 comments · 6 replies
Discussion options

You must be logged in to vote
bool parsePng(String filename, int16_t* width, int16_t* height)
{
    File file = SD.open(filename);

    if (!file)
    {
        SPI_busy = false;
        return false;
    }

    byte table[32];

    for (int i = 0; file.available() && i < 32; i++)
    {
        table[i] = file.read();
    }

    *width=table[16]*256*256*256+table[17]*256*256+table[18]*256+table[19];
    *height=table[20]*256*256*256+table[21]*256*256+table[22]*256+table[23];

    file.close();

    return true;
}

I finally make this short code for parsing a png image and retrieve dimensions.

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@paxo-rch
Comment options

@tobozo
Comment options

tobozo Oct 26, 2022
Collaborator

@paxo-rch
Comment options

Comment options

You must be logged in to vote
2 replies
@tobozo
Comment options

tobozo Oct 26, 2022
Collaborator

@paxo-rch
Comment options

Answer selected by tobozo
Comment options

You must be logged in to vote
1 reply
@tobozo
Comment options

tobozo Oct 26, 2022
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants