그래픽 라이브러리 - gxLib
글 수 28
설명
gxLib는 칼라 값을 int 나 long과 같은 한 개의 정수 변수를 이용하지 않고 아래와 같이 Red, Green, Blue, Alpha값을 따로 갖는 color_t 라는 struct 로 구성하여 사용합니다.
typedef struct color_t_ color_t;
struct color_t_
{
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char alpha;
};
예를 들어 선을 긋기 위해서는 출력 대상인 Device Context가 가지고 있는 pen_color를 변경해야 하는데, pen_color의 red, green, blue, alpha값을 직접 지정하셔도 되지만 gx_color()를 이용하여 한번에 지정하실 수 있습니다.
| 헤더 | gx.h | |||||||||
| 형태 | color_t gx_color( int red, int green, int blue, int alpah) | |||||||||
| 인수 |
| |||||||||
| 반환 |
| |||||||||
예제
아래의 예는 Screen DC를 구한 후, Screen DC를 이용하여 화면에 선을 긋습니다.
#include <stdio.h>
#include <gx.h>
int main( void)
{
dc_t *dc_screen; // 화면 Device Context
if ( gx_init( "/dev/fb")) gx_print_error( "");
else
{
if ( !( dc_screen = gx_get_screen_dc())) // 화면 출력을 위한 스크린 DC 구함
gx_print_error( ""); // 실행 중 에러가 있었다면 에러 내용을 출력
else
{
gx_clear( dc_screen, gx_color( 0, 0, 0, 255));
dc_screen->pen_color = gx_color( 255, 255, 255, 255); // 펜 색을 백색으로 지정
gx_line( dc_screen, 0, 0, gx_fb.width, gx_fb.height);
gx_release_dc( dc_screen);
}
gx_close();
}
return 0;
}



