Bitmap background


#1

Hi Guys’

I have a simple shaped bitmap i want to display on the background layer. When i display it im getting the background portion of the bitmap. So i display a 32x32 bitmap with a circle shape and i get the colored circle but also the black background it was on or white or whatever color the bitmap was on…

How do i display a bitmap without the background of that bitmap? or can i choose what part of the background is shown and what is not say like leaving a one pixel black background boarder all around the actual image i want displayed?

Thanks
Daniel


#2

Are you starting from the Bitmaps example? There is no support for transparency in bitmaps. There’s also no support for transparency in the background layer.

You could choose a specific color or range of colors that you don’t draw to the background layer. e.g. to not draw black to the background layer, change this code:

backgroundLayer.drawPixel(x + j, y + i, pixel);

to this:

if(pixel.red != 0x00 || pixel.green != 0x00 || pixel.green != 0x00) backgroundLayer.drawPixel(x + j, y + i, pixel);

A better way to do this in the future would be to add support for transparent graphical layers to SmartMatrix, and use an image format that supports transparency (e.g. GIF). A transparent graphical layer is pretty low on my list of priorities right now, so hopefully the workaround works for you.


#3

Thanks Louis, yes i started from the example… Ill try your workaround thanks for that…


#4

Workaround works like a charm, thanks Louis