Magick++
7.1.1
Loading...
Searching...
No Matches
detrans.cpp
1
//
2
// Replace transparency in an image with a solid color using Magick++
3
//
4
// Useful to see how a transparent image looks on a particular
5
// background color, or to create a similar looking effect without
6
// transparency.
7
//
8
// Copyright Bob Friesenhahn, 2000
9
//
10
// Copyright @ 2013 ImageMagick Studio LLC, a non-profit organization
11
// dedicated to making software imaging solutions freely available.
12
//
13
// Usage: detrans color file...
14
//
15
16
#include <Magick++.h>
17
#include <cstdlib>
18
#include <iostream>
19
using namespace
std;
20
using namespace
Magick;
21
int
main(
int
argc,
char
**argv)
22
{
23
if
( argc < 3 )
24
{
25
cout <<
"Usage: "
<< argv[0] <<
" background_color file..."
<< endl;
26
exit( 1 );
27
}
28
29
// Initialize ImageMagick install location for Windows
30
MagickPlusPlusGenesis
genesis(*argv);
31
32
{
33
Color
color;
34
try
{
35
color =
Color
(argv[1]);
36
}
37
catch
(
Exception
&error_ )
38
{
39
cout << error_.what() << endl;
40
cout.flush();
41
exit(1);
42
}
43
44
char
**arg = &argv[2];
45
while
( *arg )
46
{
47
string
fname(*arg);
48
try
{
49
Image
overlay( fname );
50
Image
base( overlay.size(), color );
51
base.composite( overlay, 0, 0, OverCompositeOp );
52
base.alpha(
false
);
53
base.write( fname );
54
}
55
catch
(
Exception
&error_ )
56
{
57
cout << error_.what() << endl;
58
}
59
++arg;
60
}
61
}
62
63
return
0;
64
}
Magick::Color
Definition
Color.h:37
Magick::Exception
Definition
Exception.h:25
Magick::Image
Definition
Image.h:56
Magick::MagickPlusPlusGenesis
Definition
Functions.h:44
ImageMagick-7
Magick++
demo
detrans.cpp
Generated by
1.12.0