Skip to content

Commit

Permalink
Fix off by one error in hline and vline (tuupola#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuupola authored and CHiPs44 committed Mar 30, 2023
1 parent 915f69b commit 8ba637d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hagl_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ hline(void *_bitmap, int16_t x0, int16_t y0, uint16_t width, hagl_color_t color)
{
hagl_bitmap_t *bitmap = _bitmap;

hagl_color_t *ptr = (hagl_color_t *) (bitmap->buffer + bitmap->pitch * y0 + (bitmap->depth * x0 / 8));
hagl_color_t *ptr = (hagl_color_t *) (bitmap->buffer + bitmap->pitch * y0 + (bitmap->depth / 8) * x0);
for (uint16_t x = 0; x < width; x++) {
*ptr++ = color;
}
Expand All @@ -73,7 +73,7 @@ vline(void *_bitmap, int16_t x0, int16_t y0, uint16_t height, hagl_color_t color
{
hagl_bitmap_t *bitmap = _bitmap;

hagl_color_t *ptr = (hagl_color_t *) (bitmap->buffer + bitmap->pitch * y0 + (bitmap->depth * x0 / 8));
hagl_color_t *ptr = (hagl_color_t *) (bitmap->buffer + bitmap->pitch * y0 + (bitmap->depth / 8) * x0);
for (uint16_t y = 0; y < height; y++) {
*ptr = color;
ptr += bitmap->pitch / bitmap->depth / 8;
Expand Down

0 comments on commit 8ba637d

Please sign in to comment.