Skip to content

Commit

Permalink
Fix off by one regression (see #110) (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuupola authored Mar 18, 2023
1 parent 81ee12a commit fda074c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed
- Overflow bug when resizing big bitmaps ([#102](https://github.com/tuupola/hagl/pull/102), [#49](https://github.com/tuupola/hagl/issues/49)) .
- Both horizontal and vertical lines were one pixel too short ([#110](https://github.com/tuupola/hagl/pull/110)) .
- Both horizontal and vertical lines were one pixel too short ([#110](https://github.com/tuupola/hagl/pull/110), [#111](https://github.com/tuupola/hagl/pull/111)) .

### Added
- New `hagl_bitmap_init()` function ([#98](https://github.com/tuupola/hagl/pull/98)).
Expand Down
4 changes: 2 additions & 2 deletions src/hagl_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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 / 8) * x0);
for (uint16_t x = 0; x <= width; x++) {
for (uint16_t x = 0; x < width; x++) {
*ptr++ = color;
}
}
Expand All @@ -75,7 +75,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 / 8) * x0);
for (uint16_t y = 0; y <= height; y++) {
for (uint16_t y = 0; y < height; y++) {
*ptr = color;
ptr += bitmap->pitch / (bitmap->depth / 8);
}
Expand Down

0 comments on commit fda074c

Please sign in to comment.