eevansx / glcd-arduino

Automatically exported from code.google.com/p/glcd-arduino
0 stars 0 forks source link

Cannot draw bitmaps whose height is not a multiple of 8 properly #52

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If you have a bitmap whose height is not a multiple of 8, then the last (height 
% 8) rows will not be drawn.

For example, the attached bitmap in button.h is 28x12, but it only draws the 
first 8 rows of it.

The problem lies in the for loop in line 461 of glcd.cpp; it adds rows in 
groups of 8 and discards the remainders.

Original issue reported on code.google.com by adam.gle...@gmail.com on 10 Feb 2013 at 10:34

Attachments:

GoogleCodeExporter commented 9 years ago
Yep, It is a problem.
I remember discussing this with a few people a long time ago.
I thought there was even a release note about this.
(I just looked and couldn't find it)
The problem is that the bitmap rendering code doesn't really work for all 
vertical sizes and y pixel coordinates, it never did.
It was done before I got involved with the code.
I have re-written all the other graphic code and text rendering code.
I never have gotten around to re-writing the bitmap drawing code.
The issue is that the way the code works, if the bitmap is not a multiple of 8 
pixels
in height, then there are basically two options:
truncate the image to an 8 pixel boundary (not what people want), or rendering 
the full image but potentially stomp on a few pixels up to the 8 pixel boundary 
that are just below the rendered image.
There is no simple fix. The code needs a re-write.
It is actually quite complicated to render the pixels taking into account
any possible size and any possible vertical pixel boundary, particularly
when ensuring that each LCD page gets written to only once during the
full rendering process. (That is what gives the best performance/speed)

As an interim "quick fix" you can change line 461 to this:

 for(j = 0; j < ((height+7) / 8); j++) {

And that should do about the best you can get with the current code.

I'll keep this issue open until I get a chance to re-write the code properly.

Original comment by bperry...@gmail.com on 11 Feb 2013 at 12:56