kopia lustrzana https://github.com/pimoroni/pimoroni-pico
				
				
				
			PicoGraphics: Simplify RGB565 frame convert.
Rewrite RGB565 frame convert to iterate over pixels by index, and transfer the buffer when it fills. Avoid using a bitmask so BUF_LEN can be arbitrary.mike/fix-scanline-convert
							rodzic
							
								
									bb9b5b69d3
								
							
						
					
					
						commit
						fc3060b640
					
				|  | @ -342,22 +342,22 @@ namespace pimoroni { | ||||||
|     const int BUF_LEN = 64; |     const int BUF_LEN = 64; | ||||||
|     uint16_t row_buf[2][BUF_LEN]; |     uint16_t row_buf[2][BUF_LEN]; | ||||||
|     int buf_idx = 0; |     int buf_idx = 0; | ||||||
|     for(auto y = 0; y < bounds.h; y++) { |     int buf_entry = 0; | ||||||
|         for(auto x = 0; x < bounds.w; x++) { |     for(auto i = 0; i < bounds.w * bounds.h; i++) { | ||||||
|             int buf_entry = x & (BUF_LEN - 1); |       row_buf[buf_idx][buf_entry] = get_next_pixel(); | ||||||
|             row_buf[buf_idx][buf_entry] = get_next_pixel(); |       buf_entry++; | ||||||
| 
 | 
 | ||||||
|             if (buf_entry == BUF_LEN - 1) { |       // Transfer a filled buffer and swap to the next one
 | ||||||
|                 callback(row_buf[buf_idx], BUF_LEN * sizeof(RGB565)); |       if (buf_entry == BUF_LEN) { | ||||||
|                 buf_idx ^= 1; |           callback(row_buf[buf_idx], BUF_LEN * sizeof(RGB565)); | ||||||
|             } |           buf_idx ^= 1; | ||||||
|         } |           buf_entry = 0; | ||||||
|  |       } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|         if ((bounds.w & (BUF_LEN - 1)) != 0) { |     // Transfer any remaining pixels ( < BUF_LEN )
 | ||||||
|             // Callback to the driver with the remaining row data
 |     if(buf_entry > 0) { | ||||||
|             callback(row_buf[buf_idx], (bounds.w & (BUF_LEN - 1)) * sizeof(RGB565)); |         callback(row_buf[buf_idx], buf_entry * sizeof(RGB565)); | ||||||
|             buf_idx ^= 1; |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Callback with zero length to ensure previous buffer is fully written
 |     // Callback with zero length to ensure previous buffer is fully written
 | ||||||
|  |  | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 Phil Howard
						Phil Howard