16 #include <mrpt/otherlibs/do_opencv_includes.h> 36 #if MRPT_HAS_JPEG_SYSTEM 41 #define mrpt_jpeg_source_mgr jpeg_source_mgr 43 #elif MRPT_HAS_JPEG // Built-in version 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 ],
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_set_quality(j_compress_ptr cinfo, int quality, boolean force_baseline)
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer.
init_destination(j_compress_ptr cinfo)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
mrpt_destination_mgr * mrpt_dest_ptr
jpeg_set_defaults(j_compress_ptr cinfo)
#define THROW_EXCEPTION(msg)
struct jpeg_common_struct * j_common_ptr
jpeg_finish_decompress(j_decompress_ptr cinfo)
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
jpeg_start_decompress(j_decompress_ptr cinfo)
my_source_mgr * my_src_ptr
init_source(j_decompress_ptr cinfo)
jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines)
fill_input_buffer(j_decompress_ptr cinfo)
J_COLOR_SPACE in_color_space
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
jpeg_finish_compress(j_compress_ptr cinfo)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
jpeg_destroy_decompress(j_decompress_ptr cinfo)
jpeg_stdio_src(j_decompress_ptr cinfo, CStream *in)
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
term_source(j_decompress_ptr cinfo)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
struct jpeg_destination_mgr pub
term_destination(j_compress_ptr cinfo)
void saveToStreamAsJPEG(mrpt::utils::CStream &out, const int jpeg_quality=95) const
Save image to binary stream as a JPEG (.jpg) compressed format.
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.
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
jpeg_destroy_compress(j_compress_ptr cinfo)
#define jpeg_create_decompress(cinfo)
jpeg_stdio_dest(j_compress_ptr cinfo, CStream *out)
void makeSureImageIsLoaded() const
Checks if the image is of type "external storage", and if so and not loaded yet, load it...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLenum GLenum GLvoid * row
jpeg_std_error(struct jpeg_error_mgr *err)
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
void * img
The internal IplImage pointer to the actual image content.
JOCTET * next_output_byte
#define jpeg_create_compress(cinfo)
empty_output_buffer(j_compress_ptr cinfo)
skip_input_data(j_decompress_ptr cinfo, long num_bytes)
void loadFromStreamAsJPEG(CStream &in)
Reads the image from a binary stream containing a binary jpeg file.
jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)