Back to index

tetex-bin  3.0
Classes | Functions
jpeg.h File Reference
#include <stdio.h>
#include "pdfobj.h"
#include "pdfspecial.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  jpeg

Functions

struct jpegjpeg_open (FILE *file)
int jpeg_headers (struct jpeg *jpeg)
void jpeg_close (struct jpeg *jpeg)
int check_for_jpeg (FILE *file)

Class Documentation

struct jpeg

Definition at line 34 of file jpeg.h.

Class Members
unsigned bits_per_color
unsigned colors
FILE * file
unsigned height
unsigned width

Function Documentation

int check_for_jpeg ( FILE file)

Definition at line 55 of file jpeg.c.

{
  rewind (file);
  if (get_unsigned_byte (file) != 0xff ||
      get_unsigned_byte (file) != SOI)
    return 0;
  return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void jpeg_close ( struct jpeg jpeg)

Definition at line 127 of file jpeg.c.

{
  if (jpeg == NULL) {
    fprintf (stderr, "jpeg_closed: passed invalid pointer\n");
  }
  RELEASE (jpeg);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int jpeg_headers ( struct jpeg jpeg)

Definition at line 64 of file jpeg.c.

{
  UNSIGNED_BYTE byte;
  UNSIGNED_PAIR length;
  int i, done;
  done = 0;
  while (!done) {
    if ((byte = get_unsigned_byte (jpeg -> file)) != 0xff)
      return 0;
    while ((byte = get_unsigned_byte (jpeg -> file)) == 0xff);
    length = get_unsigned_pair (jpeg -> file);
    length -= 2;
    switch (byte) {
    case SOF0:
    case SOF1:
    case SOF2:
    case SOF3:
    case SOF5:
    case SOF6:
    case SOF7:
    case SOF9:
    case SOF10:
    case SOF11:
    case SOF13:
    case SOF14:
    case SOF15:
      jpeg -> bits_per_color = get_unsigned_byte (jpeg -> file);
      jpeg -> height = get_unsigned_pair (jpeg -> file);
      jpeg -> width = get_unsigned_pair (jpeg -> file);
      jpeg -> colors = get_unsigned_byte (jpeg -> file);
      if (verbose) {
       fprintf (stderr, "ht=%d,wd=%d,co=%d,bpc=%d\n",
               jpeg->height,jpeg->width,jpeg->colors,jpeg->bits_per_color);
      }
      
      done = 1;
      return 1;
    default:
      for (i=0; i<length; i++) {
       get_unsigned_byte(jpeg -> file);
      }
    }
  }
  return 0;                 /* Not reached */
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct jpeg* jpeg_open ( FILE file) [read]

Definition at line 110 of file jpeg.c.

{
  struct jpeg *jpeg;
  if (!check_for_jpeg(file)) {
    fprintf (stderr, "\nNot a JPEG file\n");
    return NULL;
  }
  jpeg = NEW (1, struct jpeg);
  jpeg -> file = file;
  if (!jpeg_headers(jpeg)) {
    fprintf (stderr, "\nCorrupt JPEG file?\n");
    RELEASE (jpeg);
    return NULL;
  }
  return jpeg;
}

Here is the call graph for this function:

Here is the caller graph for this function: