#include "..\CookHeader.h"
#include <Windows.h>
#include <atlimage.h>
#include <conio.h>
CString filename = "C:/CookDataC/PNG/pet01.png";
COLORREF imageAry[512][512];
int ROW = 512, COL = 512;

void readImage() {
	CImage image;
	image.Load(filename);

	for (int i = 0; i < ROW; i++)
		for (int k = 0; k < COL; k++)
			imageAry[i][k] = image.GetPixel(k, i);
}

void printImage() {
	HWND hwnd;
	HDC hdc;
	hwnd = GetForegroundWindow();
	hdc = GetDC(hwnd);  // hdc = GetDC(NULL);

	for (int i = 0; i < ROW; i++)
		for (int k = 0; k < COL; k++) {
			int r = GetRValue(imageAry[i][k]);
			int g = GetGValue(imageAry[i][k]);
			int b = GetBValue(imageAry[i][k]);
			SetPixel(hdc, k + 100, i + 100, RGB(r, g, b));
		}
	ReleaseDC(hwnd, hdc);
}

int main() {
	_getch();
	readImage();

	Array <int> photoAry;
	for (int i = 0; i < ROW; i++)
		for (int k = 0; k < COL; k++) {
			int r = GetRValue(imageAry[i][k]);
			int g = GetGValue(imageAry[i][k]);
			int b = GetBValue(imageAry[i][k]);
			int value = (r + g + b) / 3;
			photoAry.push_back(value);
		}

	// 이 부분에 필요한 내용을 추가

	printImage();
}