Changes in uspace/lib/c/include/io/pixelmap.h [6d527cff:4805495] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/io/pixelmap.h
r6d527cff r4805495 42 42 #include <stddef.h> 43 43 #include <io/pixel.h> 44 45 /* Defines how a pixel outside of pixmap rectangle shall be treated */ 46 typedef enum { 47 /* Pixels outside of a pixmap are PIXEL(0, 0, 0, 0) */ 48 PIXELMAP_EXTEND_TRANSPARENT_BLACK = 0, 49 50 /* The pixmap is repeated infinetely */ 51 PIXELMAP_EXTEND_TILE, 52 53 /* If outside of a pixmap, return closest pixel from the edge */ 54 PIXELMAP_EXTEND_SIDES, 55 56 /* 57 * If outside of a pixmap, return closest pixel from the edge, 58 * with alpha = 0 59 */ 60 PIXELMAP_EXTEND_TRANSPARENT_SIDES 61 } pixelmap_extend_t; 44 62 45 63 typedef struct { … … 88 106 } 89 107 108 static inline pixel_t pixelmap_get_extended_pixel(pixelmap_t *pixmap, 109 native_t x, native_t y, pixelmap_extend_t extend) 110 { 111 bool transparent = false; 112 if (extend == PIXELMAP_EXTEND_TILE) { 113 x %= pixmap->width; 114 y %= pixmap->height; 115 } else if (extend == PIXELMAP_EXTEND_SIDES || 116 extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES) { 117 bool transparent_outside = 118 (extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES); 119 if (x < 0) { 120 x = 0; 121 transparent = transparent_outside; 122 } else if (((sysarg_t) x) >= pixmap->width) { 123 x = pixmap->width - 1; 124 transparent = transparent_outside; 125 } 126 127 if (y < 0) { 128 y = 0; 129 transparent = transparent_outside; 130 } else if (((sysarg_t) y) >= pixmap->height) { 131 y = pixmap->height - 1; 132 transparent = transparent_outside; 133 } 134 } 135 136 if (x < 0 || ((sysarg_t) x) >= pixmap->width || 137 y < 0 || ((sysarg_t) y) >= pixmap->height) 138 return PIXEL(0, 0, 0, 0); 139 140 pixel_t pixel = pixelmap_get_pixel(pixmap, x, y); 141 142 if (transparent) 143 pixel = PIXEL(0, RED(pixel), GREEN(pixel), BLUE(pixel)); 144 145 return pixel; 146 } 147 90 148 #endif 91 149
Note:
See TracChangeset
for help on using the changeset viewer.