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 145 if (cinfo->dest ==
nullptr)
172 #define INPUT_BUF_SIZE 4096 234 if (
src->start_of_file)
245 src->pub.next_input_byte =
src->buffer;
246 src->pub.bytes_in_buffer = nbytes;
275 while (num_bytes > (
long)
src->pub.bytes_in_buffer)
277 num_bytes -= (long)
src->
pub.bytes_in_buffer;
283 src->pub.next_input_byte += (size_t)num_bytes;
284 src->pub.bytes_in_buffer -= (size_t)num_bytes;
330 if (cinfo->src ==
nullptr)
332 cinfo->src = (mrpt_jpeg_source_mgr*)(*cinfo->mem->alloc_small)(
335 src->buffer = (
JOCTET*)(*cinfo->mem->alloc_small)(
344 src->pub.resync_to_restart =
348 src->pub.bytes_in_buffer = 0;
349 src->pub.next_input_byte =
nullptr;
369 const IplImage* ipl =
static_cast<const IplImage*
>(
img);
371 const unsigned int nCols = ipl->width;
372 const unsigned int nRows = ipl->height;
373 const bool is_color = (ipl->nChannels == 3);
376 ASSERT_(nCols >= 1 && nRows >= 1)
378 ASSERT_(ipl->nChannels == 1 || ipl->nChannels == 3)
402 &cinfo, jpeg_quality ,
414 row_pointer[0] = (
JSAMPROW)
new char[ipl->widthStep];
420 if (ipl->origin == 0)
421 src = &ipl->imageData[
row * ipl->widthStep];
423 src = &ipl->imageData[(nRows - 1 -
row) * ipl->widthStep];
424 char* target = (
char*)row_pointer[0];
425 for (
unsigned int col = 0; col < nCols; col++)
441 delete[] row_pointer[0];
447 for (
unsigned int row = 0;
row < nRows;
row++)
449 if (ipl->origin == 0)
455 ->imageData[(nRows - 1 -
row) * ipl->widthStep];
524 IplImage* ipl =
static_cast<IplImage*
>(
img);
535 for (
unsigned int row = 0;
row < nRows;
row++)
547 char* target = &ipl->imageData[
row * ipl->widthStep];
549 for (
unsigned int col = 0; col < nCols; col++)
563 &ipl->imageData[
row * ipl->widthStep],
buffer[0], row_stride);
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)
for(ctr=DCTSIZE;ctr > 0;ctr--)
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)
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
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)