Programming/Linux Coding Ex12. 더블 포인터로 좌표 정의 및 사용하기 푸어맨 2016. 12. 22. 10:33 int GUI_CreateObj(GUI_OBJ *obj, int x, int y, int width, int height) { int i; obj->x = x; obj->y = y; obj->width = width; obj->height = height; obj->mem_size = width * height * fb->bits_per_pixel/8; obj->line_length = obj->width * fb->bits_per_pixel/8; obj->mem = (char **)malloc(sizeof(char *) * obj->height); obj->mem[0] = (char *)malloc(sizeof(char) * obj->mem_size); for(i = 1; i < obj->height; i++) { obj->mem[i] = obj->mem[i-1] + obj->line_length; } return 1; } static int GUI_DrawDot(GUI_OBJ *obj, int x, int y, unsigned int rgb888) { unsigned int **obj_32; obj_32 = (unsigned int **)obj->mem; // 배열의 x,y 배치가 반대로 되는 걸 주의!! // (x,y) -> obj->mem[y][x] obj_32[y][x] = color; return 1; }