2009.10.31 Saturday | 09:49

  gd を c から ふるいむかし

ここにはソース長すぎるので。

gd を c から

LboxGd

if ( Commdlg->OpenFileName( FilePath ) ) {
	Dlg->EditSetText( IDC_READONLY, FilePath );
	if ( !(Gd->Load(FilePath)) ) {
		Dlg->MsgOk("ERR");
		break;
	}

	LboxString SavePath;
	Tool.ProgramDirectory( &SavePath );
	SavePath.AddBackslash();
	SavePath.operator += ("SAVE.PNG");

	LboxGd Gd2;

	Gd->Copy( &Gd2, 50 );

	Gd2.Save( &SavePath );
}


// *********************************************************
// 伸縮コピー
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxGd::Copy( LboxGd *objGD, int nRate )
{
	if ( this->lib == NULL ) {
		this->SetLibLoadErrorMessage();
		return false;
	}

	LPFUNC_gdImageCopyResampled Dll_gdImageCopyResampled;

	Dll_gdImageCopyResampled =
		(LPFUNC_gdImageCopyResampled)GetProcAddress(
			lib, "gdImageCopyResampled@40"
		);
	if ( Dll_gdImageCopyResampled == NULL ) {
		this->SetFuncLoadErrorMessage();
		return false;
	}

	int w,w2;
	int h,h2;

	this->GetImageSize( &w, &h );
	w2 = (double)w * ( (double)nRate / (double)100 );
	h2 = (double)h * ( (double)nRate / (double)100 );

	gdImagePtr im_in;
	gdImagePtr im_out;

	if ( !(objGD->Create( w2, h2 )) ) {
		return false;
	}

	im_in = (gdImagePtr)(this->gd);
	im_out = (gdImagePtr)(objGD->gd);

	Dll_gdImageCopyResampled(
		im_out,
		im_in,
		0, 0, 0, 0,
		w2, h2,
		w, h
	);

	return true;
}