16 #include <mrpt/otherlibs/do_opencv_includes.h>
36 #if MRPT_HAS_JPEG_SYSTEM
41 #define mrpt_jpeg_source_mgr jpeg_source_mgr
45 #define mrpt_jpeg_source_mgr jpeg_source_mgr
58 #define OUTPUT_BUF_SIZE 4096
149 if (cinfo->dest == NULL) {
176 #define INPUT_BUF_SIZE 4096
239 if (
src->start_of_file)
250 src->pub.next_input_byte =
src->buffer;
251 src->pub.bytes_in_buffer = nbytes;
280 while (num_bytes > (
long)
src->pub.bytes_in_buffer) {
281 num_bytes -= (long)
src->
pub.bytes_in_buffer;
287 src->pub.next_input_byte += (size_t) num_bytes;
288 src->pub.bytes_in_buffer -= (size_t) num_bytes;
337 if (cinfo->src == NULL)
339 cinfo->src = (mrpt_jpeg_source_mgr *)
355 src->pub.bytes_in_buffer = 0;
356 src->pub.next_input_byte = NULL;
378 const IplImage *ipl =
static_cast<const IplImage*
>(
img);
380 const unsigned int nCols = ipl->width;
381 const unsigned int nRows = ipl->height;
382 const bool is_color = (ipl->nChannels==3);
388 ASSERT_(ipl->nChannels == 1 || ipl->nChannels == 3)
422 row_pointer[0] = (
JSAMPROW)
new char[ ipl->widthStep ];
424 for (
unsigned int row = 0;
row<nRows;
row++)
428 if (ipl->origin == 0)
429 src = &ipl->imageData[
row * ipl->widthStep ];
430 else src = &ipl->imageData[ (nRows-1-
row) * ipl->widthStep ];
431 char *target = (
char *)row_pointer[0];
432 for (
unsigned int col=0;col<nCols;col++)
448 delete[] row_pointer[0];
454 for (
unsigned int row = 0;
row<nRows;
row++)
456 if (ipl->origin == 0)
457 row_pointer[0] = (
JSAMPROW) &ipl->imageData[
row * ipl->widthStep ];
458 else row_pointer[0] = (
JSAMPROW) &ipl->imageData[ (nRows-1-
row) * ipl->widthStep ];
526 IplImage *ipl =
static_cast<IplImage*
>(
img);
537 for (
unsigned int row = 0;
row<nRows;
row++)
549 char *target = &ipl->imageData[
row * ipl->widthStep ];
551 for (
unsigned int col=0;col<nCols;col++)
564 memcpy( &ipl->imageData[
row * ipl->widthStep ],
term_source(j_decompress_ptr cinfo)
my_source_mgr * my_src_ptr
term_destination(j_compress_ptr cinfo)
mrpt_destination_mgr * mrpt_dest_ptr
fill_input_buffer(j_decompress_ptr cinfo)
init_destination(j_compress_ptr cinfo)
empty_output_buffer(j_compress_ptr cinfo)
init_source(j_decompress_ptr cinfo)
skip_input_data(j_decompress_ptr cinfo, long num_bytes)
jpeg_stdio_src(j_decompress_ptr cinfo, CStream *in)
jpeg_stdio_dest(j_compress_ptr cinfo, CStream *out)
void * img
The internal IplImage pointer to the actual image content.
void changeSize(unsigned int width, unsigned int height, TImageChannels nChannels, bool originTopLeft)
Resize the buffers in "img" to accomodate a new image size and/or format.
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
void loadFromStreamAsJPEG(CStream &in)
Reads the image from a binary stream containing a binary jpeg file.
void saveToStreamAsJPEG(mrpt::utils::CStream &out, const int jpeg_quality=95) const
Save image to binary stream as a JPEG (.jpg) compressed format.
void makeSureImageIsLoaded() const
Checks if the image is of type "external storage", and if so and not loaded yet, load it.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer.
GLenum GLenum GLvoid * row
void BASE_IMPEXP memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) MRPT_NO_THROWS
An OS and compiler independent version of "memcpy".
jpeg_destroy_compress(j_compress_ptr cinfo)
jpeg_finish_compress(j_compress_ptr cinfo)
jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines)
jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
jpeg_set_quality(j_compress_ptr cinfo, int quality, boolean force_baseline)
jpeg_set_defaults(j_compress_ptr cinfo)
jpeg_destroy_decompress(j_decompress_ptr cinfo)
jpeg_finish_decompress(j_decompress_ptr cinfo)
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
jpeg_start_decompress(j_decompress_ptr cinfo)
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
jpeg_std_error(struct jpeg_error_mgr *err)
struct jpeg_common_struct * j_common_ptr
#define jpeg_create_decompress(cinfo)
#define jpeg_create_compress(cinfo)
#define THROW_EXCEPTION(msg)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
J_COLOR_SPACE in_color_space
JOCTET * next_output_byte
struct jpeg_destination_mgr pub