[질문]C로 GD Library 사용중 에러 발생...

paraline의 이미지

안녕하세요?

얼마전에 솔라리스에서 이미지 프로세싱하는 방법에 대해서 질문드렸던 사람입니다.
여러분들의 조언으로 gd library를 써보기로 하고, 일단 윈도용 라이브러리를 받아서 테스트 했습니다.

MFC 프로젝트를 만들어서 샘플코드를 그대로 실행시켰는데, 컴파일은 잘 됐지만, 실행시 에러가 발생합니다.
gdImagePng(), gdImageJpeg()을 호출할때, written 에러 메세지가 뜨면서 죽어버리는데, 이유를 모르겠네요.

일단은 gd library 사이트에 있는대로 환경설정도 하고, 샘플코드도 그대로 써봤는데, 왜 에러가 나는지...

혹시 저와 같은 경우가 있으셨던 분들께서는 조언 좀 해주세요.

답변 주실 모든분들께 미리 감사의 말씀 전합니다.

참고로, 소스의 일부를 올립니다.
1. Settings에서 bgd.lib를 추가했고, bgd.dll을 해당 디렉토리에 복사했습니다.
2. #include "gd.h"를 했습니다.
3. 버튼을 누르면 아래의 코드가 실행되도록 했습니다.

/////////////////////////////////////////////////////////////////////////////////
void CGdtestDlg::OnButtonGdTest() 
{
	// TODO: Add your control notification handler code here
	gdImagePtr im;
	/* Declare output files */
	FILE *pngout, *jpegout;
	/* Declare color indexes */
	int black;
	int white;
	
	/* Allocate the image: 64 pixels across by 64 pixels tall */
	im = gdImageCreate(64, 64);

	/* Allocate the color black (red, green and blue all minimum).
    Since this is the first color in a new image, it will
    be the background color. */
	black = gdImageColorAllocate(im, 0, 0, 0);  
	
	/* Allocate the color white (red, green and blue all maximum). */
	white = gdImageColorAllocate(im, 255, 255, 255);  
	
	/* Draw a line from the upper left to the lower right,
    using white color index. */
	gdImageLine(im, 0, 0, 63, 63, white);  
	
	/* Open a file for writing. "wb" means "write binary", important
    under MSDOS, harmless under Unix. */
	pngout = fopen("test.png", "wb");
	
	/* Do the same for a JPEG-format file. */
	jpegout = fopen("test.jpg", "wb");
	
	/* Output the image to the disk file in PNG format. */
gdImagePng(im, pngout); /////////////// 에러 발생
	/* Output the same image in JPEG format, using the default
    JPEG quality setting. */
gdImageJpeg(im, jpegout, -1); /////////////// 에러 발생
	
	/* Close the files. */
	fclose(pngout);
	fclose(jpegout);
	
	/* Destroy the image in memory. */
	gdImageDestroy(im);
	
}
/////////////////////////////////////////////////////////////////////////////////

혹시 위에 수행한것 외에 다른것이 필요한가요?
예를 들어, libpng(?)나 libjpeg(?) 이런 종류의 라이브러리가 추가되어야 하는지요?

vinus의 이미지

컴파일시에 다른 라이버러리 링크를 하셨는지요?
예를 들자면, png 라이버리 같은 것들....

요즘은 어떤지 모르지만 예전에 사용 했던 기억으로는 gd 라이버러리 이외에도 다른 것들을 같이 묶어 줬던 기억 있습니다.

>>>행복한 웃음<<<