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

add img2code #84

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

kossnikita
Copy link
Contributor

Image to C code converter

img2code script converts images to C byte array (bitmap)

./img2code.py image.png

Which can be drawn on display by library

Example:

extern const SSD1306_bitmap_t bitmap;
ssd1306_DrawBitmap(0, 0, bitmap.bitmap, bitmap.w, bitmap.h, White);
ssd1306_UpdateScreen();

Animation

You can even convert GIF files!

./img2code.py animation.gif

This generates a bitmap for each frame, which can be accessed by index

Example:

extern const SSD1306_animation_t animation;
for(uint32_t i = 0; i < animation.frames; i++)
{
    ssd1306_DrawBitmap(0, 0, animation.frame[i], animation.w, animation.h,
                         White);
    ssd1306_UpdateScreen();
    delay_ms(200);
}

@kossnikita
Copy link
Contributor Author

kossnikita commented Apr 5, 2024

Is it possible to move scripts to /utils/ instead of /examples/? Because these are not exactly examples.

@afiskon
Copy link
Owner

afiskon commented Apr 6, 2024

Yes, feel free moving the scripts to /utils/ . Also please add an animation example to ssd1306_TestAll().

@afiskon
Copy link
Owner

afiskon commented Apr 6, 2024

I wonder if it will play badapple demo or at least part of it :) e.g. https://tenor.com/ru/view/bad-apple-manu-touhou-gif-21182229
In order to achieve this a control of playback speed and/or frame rate may be needed.
This would be a good load test for the feature.

@kossnikita
Copy link
Contributor Author

kossnikita commented Apr 6, 2024

Finally, my first Bad Apple 😂

I don't have Nucleo, so I created a project for Black Pill. It might be compatible to Nucleo board. Could you test this from your side?

Also I spot some artifacts. Black dots of white background spawn for some reason. Not sure, maybe Pillow generate them.

Do you have any gif to add to test?

@kossnikita
Copy link
Contributor Author

Not sure, maybe Pillow generate them

It looks like I was right, these dots are also present in the original images. Bruh.

image

@kossnikita kossnikita force-pushed the feature/img2code branch 2 times, most recently from f013249 to 67930a9 Compare April 7, 2024 17:15
@afiskon
Copy link
Owner

afiskon commented Apr 15, 2024

I just thought it would be fun to use a piece of BadApple animation. I realize it's a large demo and will probably require using an external SD card and loading the frames in the runtime. All this is out of scope of the pull request. Feel free using any GIF you like in order to test the functionality.

Please rebase the PR.

@kossnikita
Copy link
Contributor Author

Do you mean remove bad apple demo from the library?

@kossnikita kossnikita force-pushed the feature/img2code branch 2 times, most recently from cb58f07 to 8c017f1 Compare April 19, 2024 10:05
@afiskon
Copy link
Owner

afiskon commented May 26, 2024

No I meant that I don't insist on using Bad Apple if this is too much effort.

The PR looks good to me. If there are no last-minute changes I'm going to merge it.

@kossnikita
Copy link
Contributor Author

This PR still needed a test case

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

Successfully merging this pull request may close these issues.

2 participants