lpcware

Rounded corner bitmaps more efficient

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by amlwwalker on Tue Oct 29 11:33:50 MST 2013
hi everyone.
LPC1788 here.
I've written some code which Im quite proud of that draws a bitmap to the lcd but rounds the corners by a certain radius. The benefit over bitmaps with the corners already rounded is that you get the background colour in the corners rather than "white" or whatever colour is on the bitmap. (see picture attached).

Anyway, here is my code, I just wonderd whether anyone can see a more efficient way of doing it - or anything im doing more than once unnecessarily as I can just see it rendering the screen (it does the same thing for all 10 images).
What its doing is going through each pixel of the bitmap, and checking which corner its in.
Then it passes the coordinates of the pixel to a function that checks whether that pixel is within the bounds of the corner (a quarter of the bresseheim circle algorithm). If it is then it plots that pixel.

Any improvements would be much appreciated.
Alex

Attachments

Outcomes