This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathimage-filter.hh
97 lines (86 loc) · 2.93 KB
/
image-filter.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Copyright © 2008-2017 Jakub Wilk <[email protected]>
* Copyright © 2009 Mateusz Turcza
*
* This file is part of pdf2djvu.
*
* pdf2djvu is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* pdf2djvu is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#ifndef PDF2DJVU_IMAGE_FILTER_H
#define PDF2DJVU_IMAGE_FILTER_H
#include <ostream>
#include <stdexcept>
#include "pdf-backend.hh"
#include "config.hh"
#include "i18n.hh"
class Quantizer
{
protected:
const Config &config;
public:
virtual void operator()(pdf::Renderer *out_fg, pdf::Renderer *out_bg, int width, int height,
int *background_color, bool &has_foreground, bool &has_background, std::ostream &stream) = 0;
explicit Quantizer(const Config &config) : config(config) { }
virtual ~Quantizer()
{ }
};
class DefaultQuantizer : public Quantizer
{
public:
explicit DefaultQuantizer(const Config &config)
: Quantizer(config)
{ }
virtual void operator()(pdf::Renderer *out_fg, pdf::Renderer *out_bg, int width, int height,
int *background_color, bool &has_foreground, bool &has_background, std::ostream &stream);
};
class WebSafeQuantizer : public Quantizer
{
protected:
void output_web_palette(std::ostream &stream);
public:
explicit WebSafeQuantizer(const Config &config)
: Quantizer(config)
{ }
virtual void operator()(pdf::Renderer *out_fg, pdf::Renderer *out_bg, int width, int height,
int *background_color, bool &has_foreground, bool &has_background, std::ostream &stream);
};
class MaskQuantizer : public Quantizer
{
public:
explicit MaskQuantizer(const Config &config)
: Quantizer(config)
{ }
virtual void operator()(pdf::Renderer *out_fg, pdf::Renderer *out_bg, int width, int height,
int *background_color, bool &has_foreground, bool &has_background, std::ostream &stream);
};
class DummyQuantizer : public Quantizer
{
public:
explicit DummyQuantizer(const Config &config)
: Quantizer(config)
{ }
virtual void operator()(pdf::Renderer *out_fg, pdf::Renderer *out_bg, int width, int height,
int *background_color, bool &has_foreground, bool &has_background, std::ostream &stream);
};
class GraphicsMagickQuantizer : public Quantizer
{
public:
explicit GraphicsMagickQuantizer(const Config &config);
virtual void operator()(pdf::Renderer *out_fg, pdf::Renderer *out_bg, int width, int height,
int *background_color, bool &has_foreground, bool &has_background, std::ostream &stream);
class NotImplementedError : public std::runtime_error
{
public:
NotImplementedError()
: std::runtime_error(_("pdf2djvu was built without GraphicsMagick; advanced color quantization is disabled."))
{ }
};
};
#endif
// vim:ts=2 sts=2 sw=2 et