-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Change pixel size of "LA", "La", and "PA" from 4 to 2 #6503
Comments
This doesn't seem right to me. A byte is 8 bits, allowing for each channel to have a range of 0 to 255 - the maximum value of Pillow/src/libImaging/Imaging.h Lines 93 to 95 in 5a087cc
Your past self also agrees with me.
|
It's here: Pillow/src/libImaging/Storage.c Lines 211 to 230 in 5a087cc
First |
Oh, ok. I guess I was wrong. Thanks for that. |
EDIT: You beat me by a few minutes :) If I understand this snippet initializing new images correctly, there are already existing modes with Pillow/src/libImaging/Storage.c Lines 220 to 230 in 5a087cc
|
FWIW this list may be helpful for implementing support for >4 byte images, tracked in #1888. |
I'm still debugging it, but I wanted to commit something, so here's what I have so far: Yay295@2643a3d |
I would say no, because "LA", "La", and "PA" are still 4 bytes. |
These image modes currently use 4 bytes for each pixel, but they only need two. I've started looking into this, but there are a lot more changes than I expected, so I'm creating this issue for documentation. The files I've found that need to be changed are:
ImagingAccessInit()
contains a mapping to three functions (also defined in this file) for each of these modes.bicubic_filter32LA()
andbilinear_filter32LA()
.ImagingGetBBox()
creates a bit mask for the alpha channel.IMAGING_PIXEL_LA
andIMAGING_PIXEL_PA
are defined in this file, though they aren't used anywhere.j2ku_graya_la()
is currently used for both "LA" and "RGBA", so it will first have to be duplicated and renamed for "RGBA", and then the original can be modified.j2k_pack_la()
.packLA()
can be replaced withcopy2()
, andpackLAL()
needs to be modified.packLA()
is no longer used after this change, so it can be removed.fill_mask_L()
uses a mask for the alpha channel, andImagingPaste()
calls the same function for "LA" and "RGBA".ImagingNewPrologueSubtype()
.unpackLA()
andunpackLAL()
.mode_map
uses_PyAccess32_2()
for these modes.Changing
im->pixelsize
from 4 to 2 also means the image data will be stored inim->image8
instead ofim->image32
.im->image
also exists and always holds the image data. The only difference between these pointers is their type:image
ischar
,image8
isUINT8
, andimage32
isINT32
. Some functions check forim->image8
being set and do different things based on that.The text was updated successfully, but these errors were encountered: