Download pptx - Image magick++

Transcript

ImageMagick++ 임유빈 ( [email protected] )

2012.01.13

ImageMagickImageMagick++

RedHat...$ yum install ImageMagick-devel

Ubuntu...$ apt-get install libmagick++-dev

Installation

Compiling

$ c++ -o exam exam.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs`

CMake

CMakeLists.txt 1/2

find_package(ImageMagick)find_package(ImageMagick COMPONENTS Magick++ convert)

include_directories(${ImageMagick_INCLUDE_DIRS})set(LIBS ${ImageMagick_LIBRARIES})

CMake

CMakeLists.txt 2/2

add_executable(exam exam.cpp)target_link_libraries(exam ${LIBS})

#include <Magick++.h>#include <list>

using namespace Magick;using namespace std;

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

InitializeMagick(*argv); // for Windows only.}

Image class

Single Frame ManipulationRef: http://imagemagick.org/Magick++/Image.html

Image

try {

Image img1("local.gif");

Image img2(Geometry("100x100"),

32, "GIF");

Image img3;

img3.read("local.jpg");

} catch (Exception& e) {cerr << e.what() << endl;

}

Image manipulation methods...

Filters...addNoise, blur, charcoal, ...

Editors...

erase, floodFillColor, zoom, ...

Adjustments...level, levelChannel, ...

Image read & write

Image img; Blob blob;img.read("mypic.jpg");

// Manipulations...

img.magick("PNG");

img.write("mypic.png");img.write(&blob);

Drawable classes...

Providing i/f for image or text for Image::draw()Ref: http://imagemagick.org/Magick++/Drawable.html

Image

Drawable

Drawable

Image img(Geometry(500,500), Color("White"));

img.draw(DrawableCircle(100, 100, 10, 10));

img.draw(DrawableRectangle(200, 200,

10, 10));

img.display();

Using STL library!

Image img(Geometry(500,500), Color("White"));

std::list<Drawable> dl;

dl.push_back(DrawableStrokeColor("Red"));dl.push_back(DrawableStrokeWidth(5));dl.push_back(DrawableFillColor("Green"));

dl.push_back(DrawableCircle(100, 100,10, 10));

img.draw(dl);img.display();

Text Rendering...

Korean fonts installation...

Local$ mkdir ~/.fonts$ cp *.ttf ~/.fonts

$ cd ~/.fonts$ fc-cache

Korean fonts installation...

Global$ su -$ cd /usr/share/fonts$ mkdir my_ttf ; cd my_ttf$ cp ~/.fonts/*.ttf .$ cd my_ttf$ fc-cache

Image img(Geometry(500,500), Color("White"));std::list<Drawable> dl;

dl.push_back(DrawableFont(" 맑은고딕 ",NormalStyle, 800, NormalStretch));

dl.push_back(DrawableText(0, 0,"세상아 , 안녕 ?", "UTF-8"));

img.draw(dl);img.display();

DrawableFont(const std::string& family,

StyleType style,

unsigned int weight,StretchType stretch)

AnyStyle

NormalStyle

ItalicStyle

ObliqueStyle

weight:

100, 200, 300

~ 900

Normal: 400

AnyStretch

NormalStretch

UltraCondensedStr

etch ...

Thank you...