그래픽 라이브러리 - gxLib
글 수 28
설명
화면이나 Bitmap 등의 Device Context에 대해 지정된 좌표의 픽셀의 칼라 값을 변경합니다.
| 헤더 | gx.h | |||||||||||||
| 형태 | void gx_set_pixel( dc_t *dc, int coor_x, int coor_y, color_t color); | |||||||||||||
| 인수 |
| |||||||||||||
| 반환 |
| |||||||||||||
예제
예제에서는 좌측에 원을 그린 후, gx_get_pixel()과 gx_set_pixel()을 이용하여 바로 옆에 원의 그림을 복사합니다.
#include <stdio.h>
#include <gx.h>
int main( void)
{
dc_t *dc_screen; // 화면 Device Context
color_t clr_white;
color_t clr_blue;
color_t clr_get;
int ndx_x;
int ndx_y;
if ( gx_init( "/dev/fb")) // gxLib 초기화
gx_print_error( ""); // 실행 중 에러 내용을 출력
else
{
if ( !( dc_screen = gx_get_screen_dc())) // 화면 출력을 위한 스크린 DC 구함
gx_print_error( ""); // 실행 중 에러 내용을 출력
else
{
clr_white = gx_color( 255, 255, 255, 255); // 백색을 만듦
clr_blue = gx_color( 0, 0, 255, 255); // 파랑색 준비
// 화면을 깨끗하게
gx_clear( dc_screen, gx_color( 0, 0, 0, 255));
// 펜 색상을 백색으로 지정 후 선 긋기
gx_pen_color( dc_screen, clr_white);
gx_brush_color( dc_screen, clr_blue);
gx_circle( dc_screen, 100, 100, 50);
// get_pixel()과 set_pixel()을 이용하여 원을 복사
for ( ndx_y = 50; ndx_y <= 150; ndx_y++)
{
for ( ndx_x = 50; ndx_x <= 150; ndx_x++)
{
gx_get_pixel( dc_screen, ndx_x , ndx_y, &clr_get);
gx_set_pixel( dc_screen, ndx_x+150, ndx_y, clr_get);
}
}
// 화면 출력용 Device Context 사용 중지
gx_release_dc( dc_screen);
}
gx_close();
}
return 0;
}
]$ ./a.out


