png_output_description.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Harry Storbacka
27 */
28
29
30 #pragma once
31
32 #include "../Image/pixel_buffer.h"
33 #include "../../Core/IOData/file_system.h"
34
35 namespace clan
36 {
39
40 class FileSystem;
41 class PNGOutputDescription_Impl;
42 class DateTime;
43
44 enum PNGColorType
45 {
46 png_color_type_gray,
47 png_color_type_gray_alpha,
48 png_color_type_palette,
49 png_color_type_rgb,
50 png_color_type_rgb_alpha,
51 png_color_mask_palette,
52 png_color_mask_color,
53 png_color_mask_alpha
54 };
55
56 enum PNGInterlaceType
57 {
58 png_interlace_none,
59 png_interlace_adam7
60 };
61
62 enum PNGFilterMethod
63 {
64 png_filter_type_default,
65 png_intrapixel_differencing
66 };
67
68 enum PNGsRGBIntent
69 {
70 png_srgb_intent_saturation,
71 png_srgb_intent_perceptual,
72 png_srgb_intent_absolute,
73 png_srgb_intent_relative
74 };
75
76 enum PNGUnknownChunkLocation
77 {
78 png_before_plte,
79 png_before_idat,
80 png_after_idat
81 };
82
83 enum PNGOffsetUnitType
84 {
85 png_offset_pixel,
86 png_offset_micrometer
87 };
88
89 enum PNGResolutionUnitType
90 {
91 png_resolution_unknown,
92 png_resolution_meter
93 };
94
95
96 class PNGOutputDescriptionPalette
97 {
98 public:
99 PNGOutputDescriptionPalette();
100
101 public:
102 void set_colors(const std::vector<Color> &palette_colors);
103 void set_key_color(const Color &color);
104 void set_tranparent_color_indexes(const std::vector<int> &alpha_indexes);
105
106 private:
107 std::vector<Color> colors;
108 bool use_keycolor;
109 };
110
111
113 class PNGOutputDescription
114 {
115
118
119 public:
124 PNGOutputDescription(int bit_depth=8, PNGColorType color_type = png_color_type_rgb_alpha);
125
129
130 public:
131
135
136 public:
137 void add_palette(const PNGOutputDescriptionPalette &palette);
138
139 void add_comment(
140 const std::string &comment,
141 std::string &keyword, // max 79 characters.
142 const std::string &lang,
143 const std::string &translated_keyword);
144
145 void add_unknown_chunk(const std::string &name, const DataBuffer &chunk_data, PNGUnknownChunkLocation location);
146
147 void set_background_color(const Color &background_color);
148
149 void set_chromacities(const Vec2f &white, const Vec2f &red, const Vec2f &green, const Vec2f &blue);
150 void set_chromacities_XYZ(const Vec3f &red, const Vec3f &green, const Vec3f &blue);
151
152 void set_key_color(const Color &color);
153
154 void set_filter_method(PNGFilterMethod filter);
155
156 void set_gamma(float gamma);
157
158 void set_icc_profile(const std::string &profile_name, const DataBuffer &profile_data);
159
160 void set_interlace_type(PNGInterlaceType type);
161
162 void set_modification_time(const DateTime &datetime);
163
164 void set_offset_from_screen_topleft(const Vec2i &offset, PNGOffsetUnitType offset_unit_type);
165
166 void set_physical_resolution(const Vec2i &resolution, PNGResolutionUnitType resolution_type);
167
168 void set_physical_scale(int scale_units, const Sized &pixel_size_in_scale_units);
169
170 void set_srgb_intent(PNGsRGBIntent intent);
171
172 void set_significant_bits(int num_bits);
173
177
178 private:
179
180 std::shared_ptr<PNGOutputDescription_Impl> impl;
181
183 };
184
185 }
186
clan::PNGOffsetUnitType
PNGOffsetUnitType
Definition: png_output_description.h:83
clan
Definition: clanapp.h:35
clan::PNGOutputDescription::set_chromacities
void set_chromacities(const Vec2f &white, const Vec2f &red, const Vec2f &green, const Vec2f &blue)
clan::PNGUnknownChunkLocation
PNGUnknownChunkLocation
Definition: png_output_description.h:76
clan::png_resolution_meter
Definition: png_output_description.h:92
clan::PNGOutputDescription::set_gamma
void set_gamma(float gamma)
clan::png_color_type_gray
Definition: png_output_description.h:46
clan::DateTime
Date/Time class.
Definition: datetime.h:43
clan::png_interlace_none
Definition: png_output_description.h:58
clan::png_color_type_palette
Definition: png_output_description.h:48
clan::png_srgb_intent_absolute
Definition: png_output_description.h:72
clan::PNGOutputDescription::set_modification_time
void set_modification_time(const DateTime &datetime)
clan::PNGFilterMethod
PNGFilterMethod
Definition: png_output_description.h:62
clan::png_before_idat
Definition: png_output_description.h:79
clan::PNGOutputDescriptionPalette::set_tranparent_color_indexes
void set_tranparent_color_indexes(const std::vector< int > &alpha_indexes)
clan::PNGOutputDescription::set_significant_bits
void set_significant_bits(int num_bits)
clan::PNGOutputDescription
Set PNG output options. Used with PNGProvider::save().
Definition: png_output_description.h:113
clan::PNGOutputDescription::PNGOutputDescription
PNGOutputDescription(int bit_depth=8, PNGColorType color_type=png_color_type_rgb_alpha)
Create output description.
clan::png_resolution_unknown
Definition: png_output_description.h:91
clan::StyleValueType::keyword
value undefined
clan::PNGOutputDescription::set_offset_from_screen_topleft
void set_offset_from_screen_topleft(const Vec2i &offset, PNGOffsetUnitType offset_unit_type)
clan::StyleTokenType::string
@ keyword
clan::png_filter_type_default
Definition: png_output_description.h:64
clan::StyleValueType::resolution
value is a frequency
clan::PNGOutputDescription::add_unknown_chunk
void add_unknown_chunk(const std::string &name, const DataBuffer &chunk_data, PNGUnknownChunkLocation location)
clan::Sized
2D (width,height) size structure - Double
Definition: size.h:182
clan::PNGOutputDescription::set_interlace_type
void set_interlace_type(PNGInterlaceType type)
clan::png_offset_micrometer
Definition: png_output_description.h:86
clan::PNGInterlaceType
PNGInterlaceType
Definition: png_output_description.h:56
clan::png_color_mask_palette
Definition: png_output_description.h:51
clan::PNGResolutionUnitType
PNGResolutionUnitType
Definition: png_output_description.h:89
clan::Vec2< float >
clan::PNGOutputDescriptionPalette::PNGOutputDescriptionPalette
PNGOutputDescriptionPalette()
clan::PNGOutputDescription::set_chromacities_XYZ
void set_chromacities_XYZ(const Vec3f &red, const Vec3f &green, const Vec3f &blue)
clan::png_srgb_intent_relative
Definition: png_output_description.h:73
clan::PNGOutputDescription::set_background_color
void set_background_color(const Color &background_color)
clan::PNGOutputDescriptionPalette::set_colors
void set_colors(const std::vector< Color > &palette_colors)
clan::PNGOutputDescription::add_comment
void add_comment(const std::string &comment, std::string &keyword, const std::string &lang, const std::string &translated_keyword)
clan::PNGColorType
PNGColorType
Definition: png_output_description.h:44
clan::PNGsRGBIntent
PNGsRGBIntent
Definition: png_output_description.h:68
clan::png_color_mask_color
Definition: png_output_description.h:52
clan::Vec3< float >
clan::png_offset_pixel
Definition: png_output_description.h:85
clan::png_interlace_adam7
Definition: png_output_description.h:59
clan::png_color_type_rgb_alpha
Definition: png_output_description.h:50
clan::png_srgb_intent_perceptual
Definition: png_output_description.h:71
clan::png_before_plte
Definition: png_output_description.h:78
clan::PNGOutputDescription::set_physical_scale
void set_physical_scale(int scale_units, const Sized &pixel_size_in_scale_units)
clan::png_intrapixel_differencing
Definition: png_output_description.h:65
clan::png_after_idat
Definition: png_output_description.h:80
clan::PNGOutputDescriptionPalette::set_key_color
void set_key_color(const Color &color)
clan::PNGOutputDescription::set_filter_method
void set_filter_method(PNGFilterMethod filter)
clan::png_color_type_gray_alpha
Definition: png_output_description.h:47
clan::PNGOutputDescriptionPalette
Definition: png_output_description.h:96
clan::png_srgb_intent_saturation
Definition: png_output_description.h:70
clan::StyleValueType::color
value is an url
clan::DataBuffer
General purpose data buffer.
Definition: databuffer.h:42
clan::png_color_type_rgb
Definition: png_output_description.h:49
clan::PNGOutputDescription::set_key_color
void set_key_color(const Color &color)
clan::png_color_mask_alpha
Definition: png_output_description.h:53
clan::PNGOutputDescription::add_palette
void add_palette(const PNGOutputDescriptionPalette &palette)
clan::PNGOutputDescription::set_srgb_intent
void set_srgb_intent(PNGsRGBIntent intent)
clan::Color
Color description class.
Definition: color.h:46
clan::PNGOutputDescription::set_icc_profile
void set_icc_profile(const std::string &profile_name, const DataBuffer &profile_data)
clan::PNGOutputDescription::set_physical_resolution
void set_physical_resolution(const Vec2i &resolution, PNGResolutionUnitType resolution_type)
clan::StyleTokenType::comment
Whitespace.