Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
jdatadst.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"

Go to the source code of this file.

Classes

struct  my_destination_mgr

Defines

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

Typedefs

typedef my_destination_mgrmy_dest_ptr

Functions

 init_destination (j_compress_ptr cinfo)
 empty_output_buffer (j_compress_ptr cinfo)
 term_destination (j_compress_ptr cinfo)
 jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
 term_destination_file_close (j_compress_ptr cinfo)
 jpeg_file_dest (j_compress_ptr cinfo, char *outfile)
 jpeg_close_file (j_compress_ptr cinfo)

Class Documentation

struct my_destination_mgr

Definition at line 25 of file jdatadst.c.

Class Members
JOCTET * buffer
FILE * outfile

Define Documentation

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

Definition at line 34 of file jdatadst.c.


Typedef Documentation

Definition at line 32 of file jdatadst.c.


Function Documentation

Definition at line 81 of file jdatadst.c.

{
  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;

  if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
      (size_t) OUTPUT_BUF_SIZE)
    ERREXIT(cinfo, JERR_FILE_WRITE);

  dest->pub.next_output_byte = dest->buffer;
  dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 43 of file jdatadst.c.

{
  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;

  /* Allocate the output buffer --- it will be released when done with image */
  dest->buffer = (JOCTET *)
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
                              OUTPUT_BUF_SIZE * SIZEOF(JOCTET));

  dest->pub.next_output_byte = dest->buffer;
  dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
}

Here is the caller graph for this function:

Definition at line 223 of file jdatadst.c.

{
  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
  fclose(dest->outfile);
}

Here is the call graph for this function:

jpeg_file_dest ( j_compress_ptr  cinfo,
char *  outfile 
)

Definition at line 193 of file jdatadst.c.

{
  my_dest_ptr dest;

  /* The destination object is made permanent so that multiple JPEG images
   * can be written to the same file without re-executing jpeg_stdio_dest.
   * This makes it dangerous to use this manager and a different destination
   * manager serially with the same JPEG object, because their private object
   * sizes may be different.  Caveat programmer.
   */
  if (cinfo->dest == NULL) {       /* first time for this JPEG object? */
    cinfo->dest = (struct jpeg_destination_mgr *)
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
                              SIZEOF(my_destination_mgr));
  }

  dest = (my_dest_ptr) cinfo->dest;
  dest->pub.init_destination = init_destination;
  dest->pub.empty_output_buffer = empty_output_buffer;
  dest->pub.term_destination = term_destination_file_close;
  dest->outfile = fopen(outfile,"wb");
}

Here is the call graph for this function:

jpeg_stdio_dest ( j_compress_ptr  cinfo,
FILE outfile 
)

Definition at line 130 of file jdatadst.c.

{
  my_dest_ptr dest;

  /* The destination object is made permanent so that multiple JPEG images
   * can be written to the same file without re-executing jpeg_stdio_dest.
   * This makes it dangerous to use this manager and a different destination
   * manager serially with the same JPEG object, because their private object
   * sizes may be different.  Caveat programmer.
   */
  if (cinfo->dest == NULL) {       /* first time for this JPEG object? */
    cinfo->dest = (struct jpeg_destination_mgr *)
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
                              SIZEOF(my_destination_mgr));
  }

  dest = (my_dest_ptr) cinfo->dest;
  dest->pub.init_destination = init_destination;
  dest->pub.empty_output_buffer = empty_output_buffer;
  dest->pub.term_destination = term_destination;
  dest->outfile = outfile;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 106 of file jdatadst.c.

{
  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
  size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;

  /* Write any data remaining in the buffer */
  if (datacount > 0) {
    if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
      ERREXIT(cinfo, JERR_FILE_WRITE);
  }
  fflush(dest->outfile);
  /* Make sure we wrote the output file OK */
  if (ferror(dest->outfile))
    ERREXIT(cinfo, JERR_FILE_WRITE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 163 of file jdatadst.c.

{
  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
  size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;

  /* Write any data remaining in the buffer */
  if (datacount > 0) {
    if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
      ERREXIT(cinfo, JERR_FILE_WRITE);
  }
  fflush(dest->outfile);
  
  /* Make sure we wrote the output file OK */
  if (ferror(dest->outfile))
    ERREXIT(cinfo, JERR_FILE_WRITE);
  else
      fclose(dest->outfile);
}

Here is the call graph for this function:

Here is the caller graph for this function: