detrans.cpp
Go to the documentation of this file.
//
// Replace transparency in an image with a solid color using Magick++
//
// Useful to see how a transparent image looks on a particular
// background color, or to create a similar looking effect without
// transparency.
//
// Copyright Bob Friesenhahn, 2000
//
// Copyright @ 2013 ImageMagick Studio LLC, a non-profit organization
// dedicated to making software imaging solutions freely available.
//
// Usage: detrans color file...
//
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc,char **argv)
{
if ( argc < 3 )
{
cout << "Usage: " << argv[0] << " background_color file..." << endl;
exit( 1 );
}
// Initialize ImageMagick install location for Windows
InitializeMagick(*argv);
{
Color color;
try {
color = Color(argv[1]);
}
catch ( Exception &error_ )
{
cout << error_.what() << endl;
cout.flush();
exit(1);
}
char **arg = &argv[2];
while ( *arg )
{
string fname(*arg);
try {
Image overlay( fname );
Image base( overlay.size(), color );
base.composite( overlay, 0, 0, OverCompositeOp );
base.alpha( false );
base.write( fname );
}
catch( Exception &error_ )
{
cout << error_.what() << endl;
}
++arg;
}
}
return 0;
}
Magick::Exception::what
virtual const char * what() const
Definition: Exception.cpp:58
Magick::Color
class MagickPPExport Color
Definition: Color.h:18
main
int main(int argc, char **argv)
Definition: detrans.cpp:20
Magick::Image::composite
void composite(const Image &compositeImage_, const Geometry &offset_, const CompositeOperator compose_=InCompositeOp)
Definition: Image.cpp:2535
std
STL namespace.
Magick++.h
Magick::Exception
Definition: Exception.h:24
Magick::Image::size
void size(const Geometry &geometry_)
Definition: Image.cpp:1379
Magick::Color
Definition: Color.h:36
Magick
Definition: Blob.h:17
Magick::InitializeMagick
MagickPPExport void InitializeMagick(const char *path_)
Definition: Functions.cpp:45
Magick::Image
Definition: Image.h:55