그래픽스, lineDDA, lineBres, circle, ellipse
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
해당 자료는 9페이지 까지만 미리보기를 제공합니다.
9페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

그래픽스, lineDDA, lineBres, circle, ellipse에 대한 보고서 자료입니다.

목차

[Projects]
 [circle]
 [ellipse]
 [line]
 [linebres]
#1.hwp


〓〓〓〓〓〓〓〓〓〓〓〓〓〓

#1.hwp

1. 소스코드
1) lineDDA
2) lineBres
3) Circle
4) ellipse

2. 결과화면
1) lineDDA
2) lineBres
3) Circle
4) ellipse

본문내용

#1.hwp


1. 소스코드

1) lineDDA

#include
#include
// line drawing algorithms

#define ROUND(x) (int)(x+0.5)
#define HEIGHT 480
#define WIDTH 640
#define COLOR 3

unsigned char n_Image[HEIGHT][WIDTH][COLOR];
unsigned char n_color[COLOR];

void init()
{
    // 이미지초기화
    int i,j,k;    
    for( i=0; i         for( j=0; j             for( k=0; k                 n_Image[i][j][k] = 255;
}

void setPixel(int x, int y)
{
    if( x < 0 || y < 0 ) return
    if( x >= WIDTH || y >= HEIGHT ) return

    n_Image[y][x][0] = n_color[0];
    n_Image[y][x][1] = n_color[1];
    n_Image[y][x][2] = n_color[2];
}

void lineDDA(int x1, int y1, int x2, int y2, int line)
{
    int dx=x2-x1, dy=y2-y1, step, k,i=0;
    float xinc, yinc, x=(float)x1, y=(float)y1;

    if(abs(dx) > abs(dy))
        step = abs(dx);
    else
        step = abs(dy);

    xinc = dx/(float)step;
    yinc = dy/(float)step;

    if(line == 0)
    {
        for(k=0;k<=step;k++,x+=xinc,y+=yinc)
            setPixel(ROUND(x), ROUND(y)); //setPixel() can be adapted to a certain Graphics H/W.







▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒


circle.c




#include
#include
#include

// line drawing algorithms

#define ROUND(x) (int)(x+0.5)
#define HEIGHT 480
#define WIDTH 640
#define COLOR 3

unsigned char n_Image[HEIGHT][WIDTH][COLOR];
unsigned char n_color[COLOR];

void init()
{
    // 이미지 초기화
    int i,j,k;    
    for( i=0; i         for( j=0; j             for( k=0; k                 n_Image[i][j][k] = 255;
}

void setPixel(int x, int y)
{
    if( x < 0 || y < 0 ) return;
    if( x >= WIDTH || y >= HEIGHT ) return;

    n_Image[y][x][0] = n_color[0];
    n_Image[y][x][1] = n_color[1];
    n_Image[y][x][2] = n_color[2];
}

void circleMidpoint(int xCenter, int yCenter, int radius, int line)
{
    int x=0, y=radius, p = 1-radius, i=0;

    while(x<=y){
        x++;i++;
        if(line == 0)
        {
            if(p<0) p += 2*x+1;
            else{ y--; p += 2*(x-y)+1;}

            setPixel(xCenter+x, yCenter+y);
            setPixel(xCenter-x, yCenter+y);
            setPixel(xCenter+x, yCenter-y);
            setPixel(xCenter-x, yCenter-y);
            setPixel(xCenter+y, yCenter+x);
            setPixel(xCenter-y, yCenter+x);
            setPixel(xCenter+y, yCenter-x);
            setPixel(xCenter-y, yCenter-x);
        }

키워드

  • 가격3,000
  • 페이지수27페이지
  • 등록일2012.08.31
  • 저작시기2005.6
  • 파일형식압축파일(zip)
  • 자료번호#762678
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니