Skip to content

Add (un)packing between RGBA and BGRa - #2057

Merged
wiredfool merged 5 commits into
python-pillow:masterfrom
arjennienhuis:RGBa
Aug 25, 2016
Merged

wiredfool merged 5 commits into
python-pillow:masterfrom
arjennienhuis:RGBa

Conversation

@arjennienhuis

@arjennienhuis arjennienhuis commented Aug 7, 2016 •

Copy link
Copy Markdown
Contributor

Cairo uses BGRa format as its CAIRO_FORMAT_ARGB32

each pixel is a 32-bit quantity, with alpha in the upper 8 bits, then red, then green, then blue. The 32-bit quantities are stored native-endian. Pre-multiplied alpha is used. (That is, 50% transparent red is 0x80800000, not 0x80ff0000.)

This patch makes it possible to do this:

Image.frombuffer("RGBA", (im.width, im.height), data, "raw", "BGRa", im.stride, 1)

This pull request adds to #2055

It's not that the raw mode does not exist.
There is just no direct conversion.
Comment thread Tests/test_mode_bgra.py Outdated
@@ -0,0 +1,23 @@
from helper import unittest, PillowTestCase

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suppose, there is no need in the separate module. Please, move pack tests to test_lib_pack.py: TestLibPack.test_pack like unpack tests.

@arjennienhuis arjennienhuis changed the title Add packing from RGBA to BGRa Add (un)packing between RGBA and BGRa Aug 8, 2016
@homm

homm commented Aug 8, 2016

Copy link
Copy Markdown
Member

👍

@wiredfool
wiredfool merged commit 35068e3 into python-pillow:master Aug 25, 2016
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