-
Notifications
You must be signed in to change notification settings - Fork 21
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
Imageload palette has no len() #80
Comments
I was unable to reproduce this on CircuitPython 9.0.4, instead getting the expected behavior. If you are still experiencing can you please provide the version of CircuitPython you are using? It can be found by reading the boot_out.txt file in your CIRCUITPY drive. |
I think this might boil down to a difference between Palette which does have a length, and ColorConverter which does not have length. imageload will return a Palette if the loaded image is indexed, and that palette will have a length representing the number of different colors in the Palette. However if the image loaded is RGB (not indexed) then imageload would return a |
That makes sense. In that case I noticed RTD is missing information on adafruit_imageload.bmp.truecolor, so there is no mention of getting a ColorConverter object back instead of a Palette. The information given for adafruit_imageload.bmp simply states it returns a tuple of a Bitmap and a Palette so getting a ColorConverter back could be a bit of a surprise, especially for someone who isnt aware there are differences between indexed and non-indexed bitmaps. A method allowing the user to check which type of image they have (and whether or not its a supported type) may be handy, though I dont think that this is a big enough issue to merit adding code. |
Its been a while since i was messing with this but from what i remember, theres multiple types of bitmaps and you have to convert the image to the correct type of bitmap for this to work. |
Im trying to dynamically index a palette that is being loaded via imageload in circuitpython, however, when i try to get the length of the palette an error occurs saying "object of type 'ColorConverter' has no len()" code sample below:
source_bitmap, source_palette = adafruit_imageload.load("bitmap.bmp", bitmap=displayio.Bitmap, palette=displayio.Palette)
test = len(source_palette)
The text was updated successfully, but these errors were encountered: