@@ -132,7 +132,7 @@ void Canvas::addImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors)
132
132
133
133
static struct {
134
134
bool has_rle_state = false ;
135
- uint16_t dstx, dsty, srcx, srcy;
135
+ int16_t dstx, dsty, srcx, srcy;
136
136
uint32_t rle_offset;
137
137
} rle_state;
138
138
@@ -146,23 +146,23 @@ void Canvas::addImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors)
146
146
dsty = y, dstx = x; // Destination line / column index
147
147
148
148
uint16_t color = 0 ; // Persist the last fetched color value
149
- if (rle_state.has_rle_state ) { // do we have rle position data
149
+ if (rle_state.has_rle_state ) { // do we have RLE position data?
150
+ rle_state.has_rle_state = false ; // invalidate stored RLE state
150
151
dstx = rle_state.dstx ; // restore required states
151
152
dsty = rle_state.dsty ;
152
153
srcx = rle_state.srcx ;
153
154
srcy = rle_state.srcy ;
154
- bytedata = (uint8_t *)images[image].data + rle_state.rle_offset ; // restart decode from here instead of the start of data
155
- rle_state.has_rle_state = false ; // invalidate stored rle state
155
+ bytedata = (uint8_t *)images[image].data + rle_state.rle_offset ; // Restart decode from here instead of the start of data
156
156
}
157
157
158
158
bool done = false ;
159
159
while (!done) {
160
- if (dsty >= endLine -1 || srcy >= image_height -1 ) { // Store state?
161
- rle_state.dstx = dstx; // save required states
160
+ if (dsty >= endLine - 1 || srcy >= image_height - 1 ) { // Store state?
161
+ rle_state.dstx = dstx; // Save required states
162
162
rle_state.dsty = dsty;
163
163
rle_state.srcx = srcx;
164
164
rle_state.srcy = srcy;
165
- rle_state.rle_offset = bytedata - (uint8_t *)images[image].data ;; // Keep these for skipping full rle decode on future iteratons
165
+ rle_state.rle_offset = bytedata - (uint8_t *)images[image].data ;; // Keep these for skipping full RLE decode on future iteratons
166
166
}
167
167
168
168
uint8_t count = *bytedata++; // Get the count byte
@@ -193,7 +193,7 @@ void Canvas::addImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors)
193
193
srcx = 0 ; dstx = x; // May be shifted within the canvas, but usually not
194
194
if (dsty >= endLine || srcy >= image_height) { // Done with the segment or the image?
195
195
done = true ; // Set a flag to end the loop...
196
- rle_state.has_rle_state = true ; // rle state is stored
196
+ rle_state.has_rle_state = true ; // RLE state is stored
197
197
break ; // ...and break out of while(count--)
198
198
}
199
199
}
0 commit comments