ProteoWizard
Main Page
Namespaces
Classes
Files
File List
File Members
pwiz
utility
misc
Image.hpp
Go to the documentation of this file.
1
//
2
// $Id: Image.hpp 4072 2012-11-02 21:00:39Z pcbrefugee $
3
//
4
//
5
// Original author: Darren Kessner <darren@proteowizard.org>
6
//
7
// Copyright 2005 Louis Warschaw Prostate Cancer Center
8
// Cedars Sinai Medical Center, Los Angeles, California 90048
9
//
10
// Licensed under the Apache License, Version 2.0 (the "License");
11
// you may not use this file except in compliance with the License.
12
// You may obtain a copy of the License at
13
//
14
// http://www.apache.org/licenses/LICENSE-2.0
15
//
16
// Unless required by applicable law or agreed to in writing, software
17
// distributed under the License is distributed on an "AS IS" BASIS,
18
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
// See the License for the specific language governing permissions and
20
// limitations under the License.
21
//
22
23
24
#ifndef _IMAGE_HPP_
25
#define _IMAGE_HPP_
26
27
28
#include "
pwiz/utility/misc/Export.hpp
"
29
#include <memory>
30
#include <string>
31
32
33
namespace
pwiz {
34
namespace
util {
35
36
37
/// wrapper class for using 'gd' graphics library
38
class
PWIZ_API_DECL
Image
39
{
40
public
:
41
42
/// struct for holding rgb values (in [0,255])
43
struct
PWIZ_API_DECL
Color
44
{
45
int
red
;
46
int
green
;
47
int
blue
;
48
49
Color
(
int
r=0,
int
g=0,
int
b=0) : red(r), green(g), blue(b) {}
50
};
51
52
static
Color
white
() {
return
Color
(255, 255, 255);}
53
static
Color
black
() {
return
Color
(0, 0, 0);}
54
55
/// struct for holding pixel coordinates
56
struct
PWIZ_API_DECL
Point
57
{
58
int
x
;
59
int
y
;
60
61
Point
(
int
_x=0,
int
_y=0) :
x
(_x),
y
(_y) {}
62
};
63
64
enum
PWIZ_API_DECL
Align {
Left
=0x01,
CenterX
=0x02,
Right
=0x04,
Top
=0x08,
CenterY
=0x10, Bottom=0x20};
65
enum
PWIZ_API_DECL
Size {
Tiny
,
Small
,
MediumBold
,
Large
, Giant};
66
67
/// create an instance
68
/// optional output_width and output_height allows easy scaling to a desired output
69
/// image size without complicating the drawing code (default is to use logical width and height)
70
static
std::auto_ptr<Image> create(
int
logical_width,
int
logical_height,
71
int
output_width=-1,
int
output_height=-1);
// -1 means use logical
72
73
/// draw pixel
74
virtual
void
pixel(
const
Point& point,
const
Color& color) = 0;
75
76
/// draw string
77
virtual
void
string(
const
std::string& text,
const
Point& point,
const
Color& color,
78
Size size=
Large
,
int
align=
Left
|
Top
) = 0;
79
80
/// draw string
81
virtual
void
stringUp(
const
std::string& text,
const
Point& point,
const
Color& color,
82
Size size=
Large
,
int
align=
Left
|
Top
) = 0;
83
84
/// draw rectangle
85
virtual
void
rectangle(
const
Point& point1,
const
Point& point2,
const
Color& color,
86
bool
filled=
true
) = 0;
87
88
/// draw circle
89
virtual
void
circle(
const
Point& center,
int
radius,
const
Color& color,
90
bool
filled=
true
) = 0;
91
92
/// draw line
93
virtual
void
line(
const
Point& point1,
const
Point& point2,
const
Color& color) = 0;
94
95
/// set clipping rectangle
96
virtual
void
clip(
const
Point& point1,
const
Point& point2) = 0;
97
98
/// write png file
99
virtual
bool
writePng(
const
char
* filename)
const
= 0;
100
101
virtual
~Image
(){}
102
};
103
104
105
inline
Image::Point
operator+
(
const
Image::Point
& a,
const
Image::Point
& b)
106
{
107
return
Image::Point
(a.
x
+b.
x
, a.
y
+b.
y
);
108
}
109
110
111
inline
Image::Point
operator-
(
const
Image::Point
& a,
const
Image::Point
& b)
112
{
113
return
Image::Point
(a.
x
-b.
x
, a.
y
-b.
y
);
114
}
115
116
117
}
// namespace util
118
}
// namespace pwiz
119
120
121
#endif // _IMAGE_HPP_
Generated on Mon Nov 26 2012 18:05:49 for ProteoWizard by
1.8.1.1