COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
jdatadst.cpp File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"
Include dependency graph for jdatadst.cpp:

Classes

struct  my_destination_mgr
 

Macros

#define OUTPUT_BUF_SIZE   4096 /* choose an efficiently fwrite'able size */
 

Typedefs

typedef my_destination_mgrmy_dest_ptr
 

Functions

static void init_destination (j_compress_ptr cinfo)
 
static boolean empty_output_buffer (j_compress_ptr cinfo)
 
static void term_destination (j_compress_ptr cinfo)
 
void jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
 

Macro Definition Documentation

#define OUTPUT_BUF_SIZE   4096 /* choose an efficiently fwrite'able size */

Typedef Documentation

Function Documentation

static void init_destination ( j_compress_ptr  cinfo)
static
44 {
45  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
46 
47  /* Allocate the output buffer --- it will be released when done with image */
48  dest->buffer = (JOCTET *)
49  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
51 
52  dest->pub.next_output_byte = dest->buffer;
54 }
Definition: jdatadst.cpp:25
size_t free_in_buffer
Definition: jpeglib.h:720
void *(* alloc_small)()
Definition: jpeglib.h:764
Definition: jpeglib.h:258
#define SIZEOF(object)
Definition: jinclude.h:80
#define JPOOL_IMAGE
Definition: jpeglib.h:754
struct jpeg_destination_mgr pub
Definition: jdatadst.cpp:26
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:274
my_destination_mgr * my_dest_ptr
Definition: jdatadst.cpp:32
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:277
#define OUTPUT_BUF_SIZE
Definition: jdatadst.cpp:34
JOCTET * buffer
Definition: jdatadst.cpp:29
char JOCTET
Definition: jmorecfg.h:115
JOCTET * next_output_byte
Definition: jpeglib.h:719
static boolean empty_output_buffer ( j_compress_ptr  cinfo)
static
82 {
83  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
84 
85  if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
86  (size_t) OUTPUT_BUF_SIZE)
87  ERREXIT(cinfo, JERR_FILE_WRITE);
88 
89  dest->pub.next_output_byte = dest->buffer;
91 
92  return TRUE;
93 }
Definition: jdatadst.cpp:25
FILE * outfile
Definition: jdatadst.cpp:28
size_t free_in_buffer
Definition: jpeglib.h:720
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
#define JFWRITE(file, buf, sizeofbuf)
Definition: jinclude.h:90
Definition: jerror.h:83
struct jpeg_destination_mgr pub
Definition: jdatadst.cpp:26
my_destination_mgr * my_dest_ptr
Definition: jdatadst.cpp:32
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:277
#define OUTPUT_BUF_SIZE
Definition: jdatadst.cpp:34
#define TRUE
Definition: jpleph.cpp:68
JOCTET * buffer
Definition: jdatadst.cpp:29
JOCTET * next_output_byte
Definition: jpeglib.h:719
static void term_destination ( j_compress_ptr  cinfo)
static
107 {
108  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
109  size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
110 
111  /* Write any data remaining in the buffer */
112  if (datacount > 0) {
113  if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
114  ERREXIT(cinfo, JERR_FILE_WRITE);
115  }
116  fflush(dest->outfile);
117  /* Make sure we wrote the output file OK */
118  if (ferror(dest->outfile))
119  ERREXIT(cinfo, JERR_FILE_WRITE);
120 }
Definition: jdatadst.cpp:25
FILE * outfile
Definition: jdatadst.cpp:28
size_t free_in_buffer
Definition: jpeglib.h:720
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
#define JFWRITE(file, buf, sizeofbuf)
Definition: jinclude.h:90
Definition: jerror.h:83
struct jpeg_destination_mgr pub
Definition: jdatadst.cpp:26
my_destination_mgr * my_dest_ptr
Definition: jdatadst.cpp:32
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:277
#define OUTPUT_BUF_SIZE
Definition: jdatadst.cpp:34
JOCTET * buffer
Definition: jdatadst.cpp:29
void jpeg_stdio_dest ( j_compress_ptr  cinfo,
FILE *  outfile 
)
131 {
132  my_dest_ptr dest;
133 
134  /* The destination object is made permanent so that multiple JPEG images
135  * can be written to the same file without re-executing jpeg_stdio_dest.
136  * This makes it dangerous to use this manager and a different destination
137  * manager serially with the same JPEG object, because their private object
138  * sizes may be different. Caveat programmer.
139  */
140  if (cinfo->dest == NULL) { /* first time for this JPEG object? */
141  cinfo->dest = (struct jpeg_destination_mgr *)
142  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
144  }
145 
146  dest = (my_dest_ptr) cinfo->dest;
150  dest->outfile = outfile;
151 }
static void term_destination(j_compress_ptr cinfo)
Definition: jdatadst.cpp:106
Definition: jdatadst.cpp:25
FILE * outfile
Definition: jdatadst.cpp:28
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:266
void *(* alloc_small)()
Definition: jpeglib.h:764
#define SIZEOF(object)
Definition: jinclude.h:80
struct jpeg_destination_mgr pub
Definition: jdatadst.cpp:26
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:274
void(* init_destination)()
Definition: jpeglib.h:722
my_destination_mgr * my_dest_ptr
Definition: jdatadst.cpp:32
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:277
Definition: jpeglib.h:718
boolean(* empty_output_buffer)()
Definition: jpeglib.h:723
static boolean empty_output_buffer(j_compress_ptr cinfo)
Definition: jdatadst.cpp:81
static void init_destination(j_compress_ptr cinfo)
Definition: jdatadst.cpp:43
#define JPOOL_PERMANENT
Definition: jpeglib.h:753
void(* term_destination)()
Definition: jpeglib.h:724