@@ -128,6 +128,9 @@ void displayio_bitmap_set_dirty_area(displayio_bitmap_t *self, const displayio_a
128
128
}
129
129
130
130
void displayio_bitmap_write_pixel (displayio_bitmap_t * self , int16_t x , int16_t y , uint32_t value ) {
131
+ if (self -> read_only ) {
132
+ mp_raise_RuntimeError (translate ("Read-only" ));
133
+ }
131
134
// Writes the color index value into a pixel position
132
135
// Must update the dirty area separately
133
136
@@ -160,6 +163,9 @@ void displayio_bitmap_write_pixel(displayio_bitmap_t *self, int16_t x, int16_t y
160
163
161
164
void common_hal_displayio_bitmap_blit (displayio_bitmap_t * self , int16_t x , int16_t y , displayio_bitmap_t * source ,
162
165
int16_t x1 , int16_t y1 , int16_t x2 , int16_t y2 , uint32_t skip_index , bool skip_index_none ) {
166
+ if (self -> read_only ) {
167
+ mp_raise_RuntimeError (translate ("Read-only" ));
168
+ }
163
169
// Copy region of "source" bitmap into "self" bitmap at location x,y in the "self"
164
170
// If skip_value is encountered in the source bitmap, it will not be copied.
165
171
// If skip_value is `None`, then all pixels are copied.
@@ -213,6 +219,9 @@ void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16
213
219
}
214
220
215
221
void common_hal_displayio_bitmap_set_pixel (displayio_bitmap_t * self , int16_t x , int16_t y , uint32_t value ) {
222
+ if (self -> read_only ) {
223
+ mp_raise_RuntimeError (translate ("Read-only" ));
224
+ }
216
225
// update the dirty region
217
226
displayio_area_t a = {x , y , x + 1 , y + 1 , NULL };
218
227
displayio_bitmap_set_dirty_area (self , & a );
@@ -223,19 +232,25 @@ void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *self, int16_t x,
223
232
}
224
233
225
234
displayio_area_t * displayio_bitmap_get_refresh_areas (displayio_bitmap_t * self , displayio_area_t * tail ) {
226
- if (self -> dirty_area .x1 == self -> dirty_area .x2 ) {
235
+ if (self -> dirty_area .x1 == self -> dirty_area .x2 || self -> read_only ) {
227
236
return tail ;
228
237
}
229
238
self -> dirty_area .next = tail ;
230
239
return & self -> dirty_area ;
231
240
}
232
241
233
242
void displayio_bitmap_finish_refresh (displayio_bitmap_t * self ) {
243
+ if (self -> read_only ) {
244
+ return ;
245
+ }
234
246
self -> dirty_area .x1 = 0 ;
235
247
self -> dirty_area .x2 = 0 ;
236
248
}
237
249
238
250
void common_hal_displayio_bitmap_fill (displayio_bitmap_t * self , uint32_t value ) {
251
+ if (self -> read_only ) {
252
+ mp_raise_RuntimeError (translate ("Read-only" ));
253
+ }
239
254
displayio_area_t a = {0 , 0 , self -> width , self -> height , NULL };
240
255
displayio_bitmap_set_dirty_area (self , & a );
241
256
0 commit comments