-
Notifications
You must be signed in to change notification settings - Fork 3
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 support for writing images with alpha / simplify working with images #107
Conversation
- fix writing binary/indexed images (by falling back to ARGB/RGB models)
Thanks for the implementation and great write up
I think I'd prefer to replace the old instructions instead of adding new ones, there have been plenty of other breaking changes since v0.4 so it is probably time to upgrade to v0.5 anyway.
Currently a
I think this is a good decision based on the factors you mentioned The documentation looks good, though it does remind me that the documentation design is pretty dated and could probably use some updates like referencing other documentation (I like the hints you added), or storing documentation as objects instead of long strings so they are more versatile. Maybe something I can think about after v0.5... |
- update 'image.aya' and 'filesystem.aya' - fix file resolution for :{image.read2}
Alright, I've updated the .aya files. |
I merged the latest master into this branch and it looks like our automatic testing caught an issue with image reading and writing. The image that is being read in has an alpha channel but the test does not.
|
Oops, you're right. |
I tried running the test script and got errors for the formats. I updated the script to use Updated script Errors: Generally they are all related to the image writer format: |
I believe this is the expected behaviour. From my initial dev-test notes:
I used Java 8. Where the JPG writer does not check if the image has alpha or not. The error message is definitely too verbose. The new error message looks like this:
|
Ah okay, missed this in your original description. I just pulled and tested everything again and it looks good to me! |
TODO
Some possibly dubious decisions
getRGB
Dev Test
The documentation shows up and looks fine (if a bit lengthy)

A "test" that tries each available format with and without alpha:
test_images.txt
(note: this test behaves differently for different java versions, it's more of an example than a test)
Results in:

line 1 of each group is the target pixel value.
line 2 is the result of 'write2 -> read2'
line 3 is the result of 'write2 -> read2 -> write2 -> read2' (looks slightly different for gif and jpg)
WBMP always fails because java expects a
MultiPixelPackedSampleModel
which isn't supported byimage.write2
.Testing on sample files worked fine however.
"sample.wbmp" :{image.read2} "sample.png" :{image.write2}
BMP+alpha fails - correctly. Since BMP does not support alpha.
GIF+alpha looks suspicious, because GIFs can only have a single transparent color-index.
JPG/JPEG+alpha is version dependent.
In Java 8 it produces the shown result.
In later versions it (correctly) refuses to write images with alpha.