pimoroni-pico icon indicating copy to clipboard operation
pimoroni-pico copied to clipboard

Trying to use convert.py to create icons to display on launcher instead but get a black square

Open Phyore opened this issue 3 years ago • 1 comments

import os
    try:
        ICONS = [f for f in os.listdir("/icons") if f.endswith(".bin")]
    except OSError:
        pass
    
    
    for i in range(max_icons):
        x = centers[i]
        label, icon = examples[i + (state["page"] * 3)]
        label = label[1:].replace("_", " ")
        display.pen(0)
        
        
        # My stuff
        file = label+'.bin'
        name = file.split(".")[0]
        
        icon = bytearray(int(64 * 64 / 8))
        try:
            open("icons/"+file, "r").readinto(icon)
            print(icon)
        except OSError:
            pass
        
        display.image(icon, 64, 64, x - 32, 24)

Trying to use the above to pull out the icons created with convert.py using the below command in Thonny. However the image displays as a simple black square in the launcher above help. %Run convert.py --binary help.png help

I am not very familiar with Python at all so I have been trying to make do with snipping functions and code from various other places (The above was from the image viewer). I however did get a version of the image working from a friend who helped me by creating the bin file in a different program.

Phyore avatar May 13 '22 15:05 Phyore

It's probably because the icon has transparency and the converter converts it to black. Try adding a white background to the icon

North101 avatar Jul 31 '22 02:07 North101

Badger 2040 and Badger 2040 W now live here: https://github.com/pimoroni/badger2040/

Both now have JPEG support, so converting icons should - with any luck - be a thing of the past.

Closing this issue to keep Badger 2040 to its new home. Please feel free to re-open over at https://github.com/pimoroni/badger2040/issues with a link back here for posterity.

Gadgetoid avatar Mar 09 '23 20:03 Gadgetoid