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 <iostream>
18
using namespace
std;
19
using namespace
Magick;
20
int
main(
int
argc,
char
**argv)
21
{
22
if
( argc < 3 )
23
{
24
cout <<
"Usage: "
<< argv[0] <<
" background_color file..."
<< endl;
25
exit( 1 );
26
}
27
28
// Initialize ImageMagick install location for Windows
29
InitializeMagick(*argv);
30
31
{
32
Color
color;
33
try
{
34
color =
Color
(argv[1]);
35
}
36
catch
(
Exception
&error_ )
37
{
38
cout << error_.what() << endl;
39
cout.flush();
40
exit(1);
41
}
42
43
char
**arg = &argv[2];
44
while
( *arg )
45
{
46
string
fname(*arg);
47
try
{
48
Image
overlay( fname );
49
Image
base( overlay.size(), color );
50
base.composite( overlay, 0, 0, OverCompositeOp );
51
base.alpha(
false
);
52
base.write( fname );
53
}
54
catch
(
Exception
&error_ )
55
{
56
cout << error_.what() << endl;
57
}
58
++arg;
59
}
60
}
61
62
return
0;
63
}
Magick::Color
Definition
Color.h:37
Magick::Exception
Definition
Exception.h:25
Magick::Image
Definition
Image.h:56
ImageMagick-7
Magick++
demo
detrans.cpp
Generated by
1.9.7