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

Pixly #1177

Merged
merged 7 commits into from Jul 4, 2016
Merged

Pixly #1177

merged 7 commits into from Jul 4, 2016

Conversation

zed9h
Copy link
Contributor

@zed9h zed9h commented Jul 2, 2016

First try at implementing the Pixly file format, just loading for now and I tested with only two files, but it could be useful to some people (for instance this guy), so I am pushing right away.

@dacap
Copy link
Member

dacap commented Jul 2, 2016

Hi @zed9h, could this use the same png encoder/decoder to avoid duplicating the whole code? I see that it opens an XML file and a png file, so to load the png file you might try to use the png decoder (or calling load_document() to load the png file as a temporal doc::Sprite/app::Document).

Also could you please sign our CLA?

@zed9h
Copy link
Contributor Author

zed9h commented Jul 2, 2016

@dacap, maybe It would be cleaner if I create a helper to decode/encode the PNG for both file formats, but first I will work on the Pixly format save, which will add more value upfront.

PS: I will read the CLA.

@dacap
Copy link
Member

dacap commented Jul 2, 2016

I'll take a look at this on next Tuesday. At the moment I recommend you to use load_document() if it's possible, so we can avoid modifying the actual png encoder/decoder (the code review from my side would be too much work if you refactor the code).

You can use Document* tmpDoc = load_document(nullptr, pngfilename) to "subload" the png file, and save_document(nullptr, tmpDoc) to save the png file.

@zed9h
Copy link
Contributor Author

zed9h commented Jul 3, 2016

I signed the CLA and finished the Pixly file save; the code ended up much simpler than the original PNG format, because it only handle RGBA, take a look if you think it worth the generalization of the codec. For me it was easier to handle a standard lib code than aseprite internal structure, even when I found the latter pretty clear and organized.

@dacap
Copy link
Member

dacap commented Jul 3, 2016

@zed9h Remember that there is an email required in the CLA signing process too.

"<PixlyAnimation version=\"1.5\">\n"
"\t<Info "
"sheetWidth=\"%d\" sheetHeight=\"%d\" "
"totalCollumns=\"%d\" totalRows=\"%d\" "

This comment was marked as spam.

@dacap
Copy link
Member

dacap commented Jul 3, 2016

As a side note, I'll need several .anim files to test these routines (original files generated with Pixly), because I don't have an Android device and cannot install Pixly. You can send me some test files at support@aseprite.org (I'll add them into an internal test suite I use for decoders/encoders)

@zed9h
Copy link
Contributor Author

zed9h commented Jul 4, 2016

@dacap Great points, I placed many more check()s and improved the error messages. I will send some good files and some bad ones to test the exceptions.

{
const Sprite* sprite = fop->document()->sprite();

if(sprite->pixelFormat() != IMAGE_RGB || !fop->document()->sprite()->needAlpha()) {

This comment was marked as spam.

@zed9h
Copy link
Contributor Author

zed9h commented Jul 4, 2016

If I remove the FILE_SUPPORT_PALETTE_WITH_ALPHA and the auto-generated palette has some alpha on it, there will be a warning every time the file is saved, so I think I will need to keep this flag, even if the palette will not be saved. I also added FILE_SUPPORT_BIG_PALETTES for the same reason. (Not really sure if this is the right way to go.)

I cleaned up some includes that seemed unnecessary.

@dacap
Copy link
Member

dacap commented Jul 4, 2016

Mhh, I think it's a bug in the code that check conditions in file.cpp. I'll be working in a fix for this so FILE*PALETTE* flags are checked only for Indexed images. (But I've to think more about those situations.)

The FILE_SUPPORT_BIG_PALETTES is in case the file format can save a color palette with more than 256 colors.

You can leave the flags and I'll then modify when the fix is done. Don't worry about that.

int imageCount = check_number<int>(xmlFrames->Attribute("length"));

if(layerCount <= 0 || imageCount <= 0) {
throw Exception("No cels found");

This comment was marked as spam.

This comment was marked as spam.

@dacap dacap merged commit 7b4a1ec into aseprite:master Jul 4, 2016
@dacap
Copy link
Member

dacap commented Jul 4, 2016

Finally I got a crash saving this file:

screen shot 2016-07-04 at 12 34 09 pm

Could you please check this issue?

@zed9h
Copy link
Contributor Author

zed9h commented Jul 4, 2016

As I suspected when I saw the line of the error, the cel image can be smaller than the sprite size, I will compensate for that.

@dacap
Copy link
Member

dacap commented Jul 5, 2016

Returning to this one: I'll finally remove FILE_SUPPORT_BIG_PALETTES and FILE_SUPPORT_PALETTE_WITH_ALPHA flags from .anim format as this format doesn't support these features (and the user must be warned that the palette will be lost). I've added the new issue #1182 how to fix the issues commented here.

@zed9h
Copy link
Contributor Author

zed9h commented Jul 5, 2016

Of course, if the palette is user created there should be a warning.

@dacap BTW, I didn't explain it properly here, the "collums" (sic) are on the official Pixly format, nothing I could do about it.

@dacap
Copy link
Member

dacap commented Jul 5, 2016

BTW, I didn't explain it properly here, the "collums" (sic) are on the official Pixly format, nothing I could do about it

👍 yeah, that's what I thought

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.

None yet

2 participants