OnDiskBitmap and Transparency

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
AmazingCircuitPythonFR35
 
Posts: 99
Joined: Thu Feb 05, 2015 10:18 am

OnDiskBitmap and Transparency

Post by AmazingCircuitPythonFR35 »

Hello,

I am working on a project using the Raspberry Pico W and a 240x135 screen. I'm reaching the limit of RAM memory.
So I'm trying to reduce the use of RAM especially on images. I replace the method "adafruit_imageload.load(...)" by the method "displayio.OnDiskBitmap(...)".

This works very well. The only problem is that I don't know how to add a transparent color with this method.
I used to use "make_transparent(...)" on the palette, but now I don't know how to do it.

Do you have an example combining "displayio.OnDiskBitmap(...)" and "make_transparent(...)"?

Thanks for your help

Mike

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: OnDiskBitmap and Transparency

Post by mikeysklar »

I do see palette.make_transparent(0) being used in the Creating Your First TileMap Game guide.

Code: Select all

# make green be transparent so entities can be drawn on top of map tiles
palette.make_transparent(0)

# Create the BANNED TileGrid
BANNED = displayio.TileGrid(
    sprite_sheet,
    pixel_shader=palette,
    width=10,
    height=8,
    tile_width=16,
    tile_height=16,
)

User avatar
AmazingCircuitPythonFR35
 
Posts: 99
Joined: Thu Feb 05, 2015 10:18 am

Re: OnDiskBitmap and Transparency

Post by AmazingCircuitPythonFR35 »

mikeysklar wrote: Mon Jan 30, 2023 1:50 pm I do see palette.make_transparent(0) being used in the Creating Your First TileMap Game guide.

Code: Select all

# make green be transparent so entities can be drawn on top of map tiles
palette.make_transparent(0)

# Create the BANNED TileGrid
BANNED = displayio.TileGrid(
    sprite_sheet,
    pixel_shader=palette,
    width=10,
    height=8,
    tile_width=16,
    tile_height=16,
)
Hi,

Thanks for your answer.
But In this example, the 'make.transparent()' method is associated with the method 'adafruit_imageload.load()'.
I would like to use it with the method 'displayio.OnDiskBitmap()' and I don't see how.

Best regards,

Mike

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”