javl / image2cpp

GNU General Public License v3.0
529 stars 156 forks source link

The generated code does not cover reality. #28

Closed Fredy12335 closed 4 years ago

Fredy12335 commented 4 years ago

Hy! I don't write much the picture says it all. Névtelen

Fredy12335 commented 4 years ago

Attaching the bitmap. ű32 I see that there were similar issues in the closed cases.

javl commented 4 years ago

I did some quick tests today and it seems the exported image is slightly too large but it does still look the way it's supposed to on my display (using the bytes I get after converting from an image). Reading the bytes back in does give me a garbled image unless I tweak the width a bit (a 21px wide image had to be read in as 24px) which adds a small border.

Still need to figure this out: I'd love to get this to work once and for all. Maybe I'd need some sort of testing system so I can easily convert multiple test images and see if the results are as expected.

Fredy12335 commented 4 years ago

Thank you for your quick reaction. if I can help you with testing or something, please let me know.

jochenderwae commented 4 years ago

This is logical.

When writing the bytes out, each line is rounded up to multiple of a byte. The input image is 21 pixels wide, so for each line 3 bytes are used (= 24 pixels but the 3 rightmost should be ignored when rendering).

The solution is to round the image width up to the nearest byte when interpreting the data.

Pull request with the solution is sent.

jochenderwae commented 4 years ago

oh and @Fredy12335 : when drawing the image on your lcd screen, specify a width of 21 pixels. Normally the drawBitmap function will ignore the trailing bits on each line and the character should be rendered as intended.

javl commented 4 years ago

I believe this was solved (thanks again, @jochenderwae) so I'm closing the issue.