뉴비입니당
bmp파일로 읽어들인 그림 정중앙에 원을 그려서 그 밖은 흑백 그 안은 색깔 있도록 코드를 짜고 싶은데 생각대로 안되네요.
bool const Circle(const double x, const double y)
{
const double x_c = 2.0;
const double y_c = 2.0;
const double r = 4.0;
const double f = (x-x_c) * (x - x_c) + (y-y_c)*(y-y_c) - r*r;
if(f > 0) return false;
else return true
}
void main()
{
int res_x, res_y;
unsigned char* rgb_array = 0;
readBMP24("dd.bmp", &res_x, &res_y, &rgb_array);
printf("%d %d\n", res_x, res_y);
for (int j = res_y - 1; j >= 0; j--)
{
for (int i = 0; i < res_x; i++)
{
unsigned char r, g, b;
const int ix = i + res_x * j;
const float red = rgb_array[ix * 3 + 0];
const float green = rgb_array[ix * 3 + 1];
const float blue = rgb_array[ix * 3 + 2];
const float gray = (red + green + blue) / 3;
if (Circle == false)
{
rgb_array[ix * 3 + 0] = gray;
rgb_array[ix * 3 + 1] = gray;
rgb_array[ix * 3 + 2] = gray;
}
}
printf("\n");
}
writeBMP24("dd.update.bmp", res_x, res_y, rgb_array);
}
이러면 될 줄 알았는데; 안되네요. 어떻게 해야할까요?
그래픽은 모름 ㅂㅂ
침착해. 이 문제를 풀 수 있는 건 너 밖에 없어.