Skip to content

Commit 6c648c6

Browse files
authored
Fix GFXcanvas16::drawFastRawHLine (#326)
This is a quick fix to fix functions like: ``` GFXcanvas16 *canvas = new GFXcanvas16 (240, 320) canvas -> fillTriangle(0, 0, 239, 0, 120, 310, ILI9341_BLUE) ``` Could all on down to drawFastRawHLine and the computerd buffer_index > 32767 which is the largest that could be held in int16_t. So switched to uint32_t also converted the computed value to uint32_t as well as to remove compiler warning. Removed another compiler warning as well. This addresses the problem in #325
1 parent 1459233 commit 6c648c6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Adafruit_GFX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,7 @@ void GFXcanvas1::drawFastRawHLine(int16_t x, int16_t y, int16_t w,
20882088

20892089
if (lastByteBits > 0) {
20902090
uint8_t lastByteBitMask = 0x00;
2091-
for (int8_t i = 0; i < lastByteBits; i++) {
2091+
for (size_t i = 0; i < lastByteBits; i++) {
20922092
#ifdef __AVR__
20932093
lastByteBitMask |= pgm_read_byte(&GFXsetBit[i]);
20942094
#else
@@ -2662,8 +2662,8 @@ void GFXcanvas16::drawFastRawVLine(int16_t x, int16_t y, int16_t h,
26622662
void GFXcanvas16::drawFastRawHLine(int16_t x, int16_t y, int16_t w,
26632663
uint16_t color) {
26642664
// x & y already in raw (rotation 0) coordinates, no need to transform.
2665-
size_t buffer_index = y * WIDTH + x;
2666-
for (int16_t i = buffer_index; i < buffer_index + w; i++) {
2665+
uint32_t buffer_index = y * WIDTH + x;
2666+
for (uint32_t i = buffer_index; i < buffer_index + w; i++) {
26672667
buffer[i] = color;
26682668
}
26692669
}

0 commit comments

Comments
 (0)