bitbank2 / JPEGDEC

An optimized JPEG decoder for Arduino
Apache License 2.0
365 stars 47 forks source link

Flatten and print Row-major #66

Closed WrelksMC closed 6 months ago

WrelksMC commented 6 months ago

Not particularly an 'issue' I am just lost as to how one would flatten a JPEG image using this library and then print all of its contents (pixel by pixel) in row-major format.

I already have my JPEG image received no problem I just need to flatten it, if someone could point me in the right direction I'd be grateful. ex: callBack(JPEGDRAW *pDraw) {...}

Edit: Thought I'd add a little more information as to what I'm saying. I have a screen that I am trying to write images to that only accepts pixels sent via row-major format. And allthough I've created functions that can iterate through my decoded jpeg file in row-major fashion it's clear that the information isn't "stored" like that - MCUs and all. I am just requesting a callBack of which will iterate through my decoded jpeg file in a way that is row-major so my screen can re-assemble the image. Am dealing with images greater than 300x300 pixels if that is of any help.

Anyway, thank you.

bitbank2 commented 6 months ago

I understand your question, but can't change the nature of JPEG encoding to suit your use case. You will need to temporarily store each row of MCUs and then send them a row at a time to your display. The JPEGDRAW callback will always complete a row of MCUs without wrapping around to the next. e.g. if the row has 24 MCUs horizontally, it might call JPEGDRAW with 20 followed by 4, but one or more calls will always add up to the full row width.