Skip to content

Add image export to farbfeld format#298

Closed
hevrard wants to merge 1 commit intogoogle:masterfrom
hevrard:farbfeld-export
Closed

Add image export to farbfeld format#298
hevrard wants to merge 1 commit intogoogle:masterfrom
hevrard:farbfeld-export

Conversation

@hevrard
Copy link
Collaborator

@hevrard hevrard commented Feb 18, 2019

Currently image export is done in PPM format, which unfortunately lacks support of alpha channel. Alpha channel support is crucial for graphicsfuzz experiments.

This change adds a possible export to farbfeld format, which both supports alpha channel and is trivial to implement, bypassing the need for a third party library. For more info, see https://tools.suckless.org/farbfeld/faq/

EDIT: PNG export would be nice as PNG is supported virtually everywhere. I prepared this farbfeld export because I assumed adding a third-party PNG library (e.g. lodepng https://github.com/lvandeve/lodepng) as an Amber dependency would be frowned upon. Yet if you can see a way of easily adding PNG export support, please let me know!

@dj2
Copy link
Collaborator

dj2 commented Feb 19, 2019

I think I'd prefer png to farbfeld as I can't find much on image editor support for farbfeld (can I open it in preview on Mac or what software do I need on Linux?)

I don't have an issue with adding the extra dependency to the samples/ app.

@hevrard
Copy link
Collaborator Author

hevrard commented Feb 19, 2019

See #301 for PNG export.

Copy link
Collaborator

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

farbfeld is super simple!


namespace {

char byte0(uint32_t word) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use uint8_t instead of char.

// Farbfeld format details: https://tools.suckless.org/farbfeld/

// Farbfeld header
std::string image = "farbfeld";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend adding image.reserve(8 +4 +4 + width * height * 4 * 2);

@hevrard hevrard closed this Feb 21, 2019
@hevrard hevrard deleted the farbfeld-export branch March 15, 2019 17:12
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.

3 participants