英文サイトなのでサンプル探すのを苦労しましたが、以下にあります http://www.imagemagick.org/Magick++/ ↓ http://www.imagemagick.org/Magick++/Documentation.html ↓ http://www.imagemagick.org/Magick++/Image.html ここから始めるのが良いと思います。ちょうど crop ですし。 ※ ファイルのパスのかわりに URL が書けます im_test.cpp 拡張子:txtvbswsfjsphpjavahtmlutf8sjis // ********************************************************* // www\Magick++\Image.html にある サンプルです // ********************************************************* #include <Magick++.h> #include <string> #include <iostream> using namespace std; using namespace Magick; int main( int argc, char argv[] ) { Image image; try { image.read( "in.png" ); // Crop the image to specified size (width, height, xOffset, yOffset) image.crop( Geometry( 380, 540, 50, 50 ) ); // Write the image to a file image.write( "out.png" ); } catch( Exception &error_ ) { printf( "エラーが発生しました : %s : ", error_.what() ); } return 1; } ↓バッチビルド用のバッケージです( ソースコードとビルド後の exe も入っています ) http://winofsql.jp/download/ImageMagick_test.lzh ビルド時のオプションは以下のようになります。 ( 実行時にはコメントや改行が削除されます ) 拡張子:txtvbswsfjsphpjavahtmlutf8sjis ;コンパイル cl.exe im_test.cpp /c /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D _CRT_SECURE_NO_DEPRECATE ; ランタイムライブラリを内部に取り込む( DLLから読まない:msvcr80.dll ) /MT ; ワーングレベル /W3 ; ************************************************ ; ImageMagick で追加 ; ************************************************ /I "C:\Program Files\ImageMagick-6.5.0-Q8\include" /EHsc ;↓ 行頭 // で行区切りをあらわします // ;リンク link.exe im_test.obj ; 参照ライブラリ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ; ************************************************ ; ImageMagick で追加 ; ************************************************ CORE_RL_magick_.lib CORE_RL_Magick++_.lib X11.lib /libpath:"C:\Program Files\ImageMagick-6.5.0-Q8\lib" ; 出力ファイル名の指定 /OUT:"im_test.exe" ※ インストールディレクトリは、C:\Program Files\ImageMagick-6.5.0-Q8 です。
// ********************************************************* // www\Magick++\Image.html にある サンプルです // ********************************************************* #include <Magick++.h> #include <string> #include <iostream> using namespace std; using namespace Magick; int main( int argc, char argv[] ) { Image image; try { image.read( "in.png" ); // Crop the image to specified size (width, height, xOffset, yOffset) image.crop( Geometry( 380, 540, 50, 50 ) ); // Write the image to a file image.write( "out.png" ); } catch( Exception &error_ ) { printf( "エラーが発生しました : %s : ", error_.what() ); } return 1; }
;コンパイル cl.exe im_test.cpp /c /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D _CRT_SECURE_NO_DEPRECATE ; ランタイムライブラリを内部に取り込む( DLLから読まない:msvcr80.dll ) /MT ; ワーングレベル /W3 ; ************************************************ ; ImageMagick で追加 ; ************************************************ /I "C:\Program Files\ImageMagick-6.5.0-Q8\include" /EHsc ;↓ 行頭 // で行区切りをあらわします // ;リンク link.exe im_test.obj ; 参照ライブラリ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ; ************************************************ ; ImageMagick で追加 ; ************************************************ CORE_RL_magick_.lib CORE_RL_Magick++_.lib X11.lib /libpath:"C:\Program Files\ImageMagick-6.5.0-Q8\lib" ; 出力ファイル名の指定 /OUT:"im_test.exe"