Guest User

Untitled

a guest
Sep 30th, 2023
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | Source Code | 0 0
  1. struct bmap32 {
  2.     struct rect f;
  3.     int32_t rows[32];
  4. };
  5. typedef struct bmap32 bmap32;
  6.  
  7. void draw_32(struct widget *w, bmap32 *m) {
  8.     for (int x = 0; x < m->f.size.x && x + m->f.start.x < w->frame.size.x; ++x) {
  9.         for (int y = 0; y < m->f.size.y && y + m->f.start.y < w->frame.size.y; ++y) {
  10.             set_pixel(w, x + m->f.start.x, y + m->f.start.y, (m->rows[y] & (0x1 << (31 - x))) ? 0xff : 0x00);
  11.         }
  12.     }
  13. }
  14.  
  15. // To use:
  16. draw_32(w, &(bmap32){
  17.     { .start = { 2, 6}, .size = { 5, 3 } },
  18.     .rows = {
  19.         0b0010000000000000 << 16,
  20.         0b0111000000000000 << 16,
  21.         0b1111100000000000 << 16,
  22.     }
  23. });
Advertisement
Add Comment
Please, Sign In to add comment