Revision 183
can reduce letter size; working on increasing
graph.c | ||
---|---|---|
1 | 1 |
#include <lcom/lcf.h> |
2 | 2 |
|
3 | 3 |
#include "graph.h" |
4 |
#include "graph_macros.h" |
|
4 |
|
|
5 | 5 |
#include "errors.h" |
6 |
|
|
7 | 6 |
#include <stdio.h> |
8 | 7 |
|
9 | 8 |
/// MACROS |
... | ... | |
245 | 244 |
|
246 | 245 |
/// PIXEL DRAWING |
247 | 246 |
int (graph_set_pixel)(uint16_t x, uint16_t y, uint32_t color) { |
248 |
if (x >= vbe_mem_info.XResolution || y >= vbe_mem_info.YResolution) { |
|
247 |
/* |
|
248 |
if (x < 0 || vbe_mem_info.XResolution <= x || y < 0 || vbe_mem_info.YResolution <= y) { |
|
249 | 249 |
//printf("%s: invalid pixel.\n", __func__); |
250 | 250 |
return OUT_OF_RANGE; |
251 | 251 |
} |
252 | 252 |
unsigned int pos = (x + y * vbe_mem_info.XResolution) * graph_get_bytes_pixel(); |
253 | 253 |
memcpy(video_buf + pos, &color, graph_get_bytes_pixel()); |
254 | 254 |
return SUCCESS; |
255 |
*/ |
|
256 |
return graph_set_pixel_buffer(x, y, color, video_buf, graph_get_XRes(), graph_get_YRes()); |
|
255 | 257 |
} |
258 |
int (graph_set_pixel_buffer)(uint16_t x, uint16_t y, uint32_t color, uint8_t *buf, uint16_t W, uint16_t H) { |
|
259 |
if (x < 0 || W <= x || y < 0 || H <= y) { |
|
260 |
//printf("%s: invalid pixel.\n", __func__); |
|
261 |
return OUT_OF_RANGE; |
|
262 |
} |
|
263 |
unsigned int pos = (x + y * W) * graph_get_bytes_pixel(); |
|
264 |
memcpy(buf + pos, &color, graph_get_bytes_pixel()); |
|
265 |
return SUCCESS; |
|
266 |
} |
|
267 |
int (graph_set_pixel_alpha_buffer)(uint16_t x, uint16_t y, uint8_t alpha, uint8_t *alp_buf, uint16_t W, uint16_t H) { |
|
268 |
if (x < 0 || W <= x || y < 0 || H <= y) { |
|
269 |
//printf("%s: invalid pixel.\n", __func__); |
|
270 |
return OUT_OF_RANGE; |
|
271 |
} |
|
272 |
unsigned int pos = x + y * W; |
|
273 |
memcpy(alp_buf + pos, &alpha, 1); |
|
274 |
return SUCCESS; |
|
275 |
} |
|
256 | 276 |
int (graph_set_pixel_alpha)(uint16_t x, uint16_t y, uint32_t color, uint8_t alpha){ |
257 | 277 |
if (x >= vbe_mem_info.XResolution || y >= vbe_mem_info.YResolution) { |
258 | 278 |
//printf("%s: invalid pixel.\n", __func__); |
259 | 279 |
return OUT_OF_RANGE; |
260 | 280 |
} |
281 |
//printf("COLOR= %X, ALPHA = %X\n", color, alpha); |
|
261 | 282 |
unsigned int pos = (x + y * vbe_mem_info.XResolution) * graph_get_bytes_pixel(); |
262 | 283 |
uint32_t color_; |
263 | 284 |
memcpy(&color_, video_buf + pos, graph_get_bytes_pixel()); |
Also available in: Unified diff