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