FelixWolf/libfurc

[BUG] Fox5Image.toPIL() appears to produce incorrect colors

Closed this issue · 1 comments

The bug
When using Fox5Image.toPIL() to convert a Fox5 image to a PIL image, the resultant image appears to have incorrect colors

  1. Original Test Image as in Fox Editor
    image

  2. Resulting image that was saved from the PIL object produced by Fox5Image.toPIL() - It appears that only the green channel from the image and arbitrary transparency is saved.
    testcard

Proposed solution

It appears that the issue is on this line here.

data += bytes((self.data[pixel+3], self.data[pixel+0], self.data[pixel+1], self.data[pixel+2]))

When the line is substituted as follows

data += bytes((self.data[pixel+1], self.data[pixel+2], self.data[pixel+3], self.data[pixel+0])) 

the colors should be saved correctly.

Test code
Below is the code snippet I used to save the above images from a fox file, for reference - in case there's something in my code that may have caused the issue instead.

from libfurc import fox5

def getImage(fox,id):
    return fox.body["ImageList"][id]

fox = fox5.load("exportTest.fox")
img = getImage(fox,0)
img = img.toPIL()
img.save("testcard.png")
#img.show()

Thanks you for the report!

Looks like I was trying to the ARGB pixel as if I were going to encode it(thus encoding it as BARG).
This has been fixed as of 6b14c1b.