[Solved] How to skip pixel with mcufriend

Hi, I would like to code a graphic function by using write16(x) instead of drawPixel which is slower. It works after setting setAddrWindow() and draw a rectangular shape. However, if I want to skip specific colors to have a for example transparency, if I don't call write16(x) it doesn't work anymore, the rectangular shape is lost. Is there a solution?

For example with a picture of 32x32 pixels:
setAddrWindow(0,0,31,31);

Inside the drawing loop:
if(color!=0){ write16(color); }
else { "??" }; //skip color 0 for transparancy but write the next pixel to right place

It depends on your controller. Most modern controllers don't let you skip a pixel. But certain older ones do.

What controller are you using?

It is fairly simple. Set a rectangle with setAddrWindow() and blit new pixels with pushColors(). Stop when you want to skip a pixel and set a fresh Window when you want to blit some more pixels.

In practice it is easier to do this one row at a time. (for landscape shapes) or one column at time for portrait rectangles.

David.

I see what you mean about recreating a new Window each time a group of visible pixels must be written but if the image is complex with many "holes" anywhere, it's an heavy procedure. I will try to see if this method can work. By the way I use an ILI9341.

An ILI9341 can't skip pixels. pushColors() is more efficient than drawPixel()

Look at your typical image. It is likely that you have 40%/60% opaque/transparent pixels. But the opaque pixels are likely to occur in bursts. Even a 2-pixel burst is better with pushColors().

Some things like Fonts are typically 10% opaque. So drawPixel() is often more efficient.

David.

You're right, I will make some tests and come back. Thanks for the answers.

Edit: tests are satisfying, I displayed an image of a filled circle, really faster than drawPixel :slight_smile: