ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文
ImageMagick で C++ アプリケーション作成( 2 ) 〜 一括処理 ( No.4 )
日時: 2009/03/20 22:19
名前: lightbox



http://www.imagemagick.org/Magick++/Image.html#Constructors にあるコンストラクタ
とメソッドのドキュメントを見ましたが、これぐらいは書かないとだめなようです。


拡張子:
// *********************************************************
// 一括処理はやはり一覧が必要
// *********************************************************

#include <windows.h>
#include <Magick++.h>
#include <string>
#include <iostream>

using namespace std;
using namespace Magick;

int main( int argc, char argv[] )
{

	HANDLE hFile;
	BOOL bRet;
	WIN32_FIND_DATA wfd;
	Image image;
	string work;

	hFile = FindFirstFile( "..\\png\\*.png", &wfd );
	bRet = true;
	while( hFile != INVALID_HANDLE_VALUE && bRet == (BOOL)true ) {

		try { 
			work = "..\\png\\";
			work += wfd.cFileName;
			image.read( work ); 
	
			image.crop( Geometry( 380, 540, 50, 50 ) ); 
	
			image.write( wfd.cFileName ); 
		} 
		catch( Exception &error_ ) { 
			printf( "エラーが発生しました : %s : ", error_.what() );
		}

		bRet = FindNextFile( hFile, &wfd );

	}
	if ( !bRet ) {
		FindClose( hFile );
	}

	return 1;
}