]> git.defcon.no Git - avrfbosd/blobdiff - draw.c
Added support for drawing 8bpp images... Updated demo a bit...
[avrfbosd] / draw.c
diff --git a/draw.c b/draw.c
index 43af32bf178edd60974a0e906bef86e2e267237a..567b923aaeda8dcfec66f7f048e3487eaece0547 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -63,7 +63,7 @@ Bresenham's line algorithm, optimized and simplified.
 void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t c)
 {
 
-       if (x0 > hres_bytes*8 || y0 > VRES || x1 > hres_bytes*8 || y1 > VRES)
+       if (x0 > hres_bytes*8 || y0 > VRES) // || x1 > hres_bytes*8 || y1 > VRES)
                return;
 
        int dx, dy, sx, sy, err, p;
@@ -78,6 +78,8 @@ void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t c)
        {
                sp(x0, y0, c);
                if ( ( x0 == x1 ) && ( y0 == y1 ) ) return;
+               if ( x0 > hres_bytes*8  || y0 > VRES ) return;
+               
                p = 2 * err;
                if ( p > -dy )
                {
@@ -189,4 +191,27 @@ void fill_circle(uint8_t x0, uint8_t y0, uint8_t radius, char c)
        _draw_circle(x0, y0, radius, c, c);
 }
 
+void draw_8bpp_bitmap( uint8_t pos_x, uint8_t pos_y, uint8_t width, uint8_t height, const uint8_t* image )
+{
+       for ( int v = 0; v < height; v++ )
+       {
+               for ( int h = 0; h < width; h++ )
+               {
+                       uint8_t t = image[v*width+h];
+                       set_pixel( pos_x + h, pos_y + v, t);
+               }
+       }
+}
+
+void pgm_draw_8bpp_bitmap( uint8_t pos_x, uint8_t pos_y, uint8_t width, uint8_t height, const uint8_t* image )
+{
+       for ( int v = 0; v < height; v++ )
+       {
+               for ( int h = 0; h < width; h++ )
+               {
+                       uint8_t t = pgm_read_byte(&(image[v*width+h]));
+                       set_pixel( pos_x + h, pos_y + v, t);
+               }
+       }
+}