30#ifndef __CLAW_JPEG_HPP__
31#define __CLAW_JPEG_HPP__
65 struct jpeg_error_mgr
pub;
98 struct jpeg_source_mgr
pub;
102 std::istream& m_input;
105 const JOCTET* m_buffer;
108 const unsigned int m_buffer_size;
111 unsigned int m_stream_size;
114 unsigned int m_stream_position;
131 class grayscale_to_pixel32
141 void load(std::istream& f);
144 template <
class Convert>
145 void read_data(jpeg_decompress_struct& cinfo,
146 const Convert& pixel_convert);
148 void read_from_file(std::istream& f);
149 void decompress(std::istream& f, jpeg_decompress_struct& cinfo);
151 void create_decompress_info(jpeg_decompress_struct& cinfo,
152 source_manager& infile)
const;
174 options(
unsigned char compression_quality_,
bool progressive_);
202 struct jpeg_destination_mgr
pub;
206 std::ostream& m_output;
212 const unsigned int m_buffer_size;
224 void set_options(jpeg_compress_struct& cinfo,
226 void save_image(jpeg_compress_struct& cinfo)
const;
228 void copy_pixel_line(JSAMPLE* data,
unsigned int y)
const;
230 void create_compress_info(jpeg_compress_struct& cinfo,
235 const image& m_image;
239 static const unsigned int s_rgb_pixel_size;
244 jpeg(
unsigned int w,
unsigned int h);
246 jpeg(std::istream& f);
248 void save(std::ostream& os,
255#include <claw/graphic/jpeg_reader.tpp>
A class to deal with images.
image()
Constructor. Creates an image without datas.
void load(std::istream &f)
Load an image from a jpeg file.
reader(image &img)
Constructor.
void save(std::ostream &f, const options &opt=options()) const
Save an image in a jpeg file.
writer(const image &img)
Constructor.
void save(std::ostream &os, const writer::options &opt=writer::options()) const
Save the image.
jpeg(unsigned int w, unsigned int h)
Constructor. Creates an empty image.
A class to deal with images.
Everything about image structures and processing.
rgba_pixel rgba_pixel_8
A color with 8 bits per component and an alpha channel.
This is the main namespace.
Error handler that throw an exception instead of exiting the program.
std::string error_string
A comprehensive description of the error.
struct jpeg_error_mgr pub
"public" fields, needed by the jpeg library.
jmp_buf setjmp_buffer
For return to caller.
void skip_input_data(long num_bytes)
Skip some bytes in the input buffer.
boolean fill_input_buffer()
Fill the input buffer with new data.
source_manager(std::istream &is)
Constructor.
~source_manager()
Destructor.
struct jpeg_source_mgr pub
"public" fields, needed by the jpeg library.
Destination manager that allow us to write in a std::ostream.
destination_manager(std::ostream &os)
Constructor.
void term()
Write the last pending bytes in the file.
struct jpeg_destination_mgr pub
"public" fields, needed by the jpeg library.
~destination_manager()
Destructor.
void flush()
Write the content of the buffer in the file.
Parameters of the writing algorithm.
bool progressive
Tell if we save a progressive jpeg.
options()
Default constructor.
unsigned char quality
Quality level to use in the saved stream.