Changes in uspace/lib/c/include/io/pixelmap.h [00ddb40:ba733e83] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/io/pixelmap.h
r00ddb40 rba733e83 1 1 /* 2 2 * Copyright (c) 2011 Petr Koupy 3 * Copyright (c) 2014 Martin Sucha4 3 * All rights reserved. 5 4 * … … 41 40 #include <unistd.h> 42 41 #include <io/pixel.h> 43 44 /* Defines how a pixel outside of pixmap rectangle shall be treated */45 typedef enum {46 /* Pixels outside of a pixmap are PIXEL(0, 0, 0, 0) */47 PIXELMAP_EXTEND_TRANSPARENT_BLACK = 0,48 49 /* The pixmap is repeated infinetely */50 PIXELMAP_EXTEND_TILE,51 52 /* If outside of a pixmap, return closest pixel from the edge */53 PIXELMAP_EXTEND_SIDES,54 55 /* If outside of a pixmap, return closest pixel from the edge,56 * with alpha = 057 */58 PIXELMAP_EXTEND_TRANSPARENT_SIDES59 } pixelmap_extend_t;60 42 61 43 typedef struct { … … 104 86 } 105 87 106 static inline pixel_t pixelmap_get_extended_pixel(pixelmap_t *pixmap,107 native_t x, native_t y, pixelmap_extend_t extend)108 {109 bool transparent = false;110 if (extend == PIXELMAP_EXTEND_TILE) {111 x %= pixmap->width;112 y %= pixmap->height;113 }114 else if (extend == PIXELMAP_EXTEND_SIDES ||115 extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES) {116 bool transparent_outside =117 (extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES);118 if (x < 0) {119 x = 0;120 transparent = transparent_outside;121 }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 }131 else if (((sysarg_t) y) >= pixmap->height) {132 y = pixmap->height - 1;133 transparent = transparent_outside;134 }135 }136 137 if (x < 0 || ((sysarg_t) x) >= pixmap->width ||138 y < 0 || ((sysarg_t) y) >= pixmap->height)139 return PIXEL(0, 0, 0, 0);140 141 pixel_t pixel = pixelmap_get_pixel(pixmap, x, y);142 143 if (transparent)144 pixel = PIXEL(0, RED(pixel), GREEN(pixel), BLUE(pixel));145 146 return pixel;147 }148 149 150 88 #endif 151 89
Note:
See TracChangeset
for help on using the changeset viewer.