- Timestamp:
- Mar 27, 2006, 11:22:34 PM (15 years ago)
- Location:
- libcaca/trunk/cucul
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/cucul.c
r677 r701 78 78 } 79 79 80 /** \brief Set the canvas size. 80 cucul_t *cucul_load(void *data, unsigned int size) 81 { 82 cucul_t *qq; 83 uint8_t *buf = (uint8_t *)data; 84 unsigned int width, height, n; 85 86 if(size < 12) 87 return NULL; 88 89 if(buf[0] != 'C' || buf[1] != 'A' || buf[2] != 'C' || buf[3] != 'A') 90 return NULL; 91 92 width = ((uint32_t)buf[4] << 24) | ((uint32_t)buf[5] << 16) 93 | ((uint32_t)buf[6] << 8) | (uint32_t)buf[7]; 94 height = ((uint32_t)buf[8] << 24) | ((uint32_t)buf[9] << 16) 95 | ((uint32_t)buf[10] << 8) | (uint32_t)buf[11]; 96 97 if(!width || !height) 98 return NULL; 99 100 if(size != 12 + width * height * 5 + 4) 101 return NULL; 102 103 qq = cucul_create(width, height); 104 105 if(!qq) 106 return NULL; 107 108 for(n = height * width; n--; ) 109 { 110 qq->chars[n] = ((uint32_t)buf[12 + 5 * n] << 24) 111 | ((uint32_t)buf[13 + 5 * n] << 16) 112 | ((uint32_t)buf[14 + 5 * n] << 8) 113 | (uint32_t)buf[15 + 5 * n]; 114 qq->attr[n] = buf[16 + 5 * n]; 115 } 116 117 return qq; 118 } 119 120 /** \brief Resize a canvas. 81 121 * 82 122 * This function sets the canvas width and height, in character cells. -
libcaca/trunk/cucul/cucul.h
r696 r701 120 120 * @{ */ 121 121 cucul_t * cucul_create(unsigned int, unsigned int); 122 cucul_t * cucul_load(void *, unsigned int); 122 123 void cucul_set_size(cucul_t *, unsigned int, unsigned int); 123 124 unsigned int cucul_get_width(cucul_t *);
Note: See TracChangeset
for help on using the changeset viewer.