Back to index

tetex-bin  3.0
Defines | Functions
jpeg.c File Reference
#include <stdio.h>
#include "system.h"
#include "mem.h"
#include "mfileio.h"
#include "numbers.h"
#include "dvi.h"
#include "jpeg.h"
#include "pdfobj.h"
#include "pdfspecial.h"

Go to the source code of this file.

Defines

#define verbose   0
#define SOF0   0xc0
#define SOF1   0xc1
#define SOF2   0xc2
#define SOF3   0xc3
#define SOF5   0xc5
#define SOF6   0xc6
#define SOF7   0xc7
#define SOF9   0xc9
#define SOF10   0xca
#define SOF11   0xcb
#define SOF13   0xcd
#define SOF14   0xce
#define SOF15   0xcf
#define SOI   0xd8
#define EOI   0xd9
#define SOS   0xda
#define COM   0xfe

Functions

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

Define Documentation

#define COM   0xfe

Definition at line 53 of file jpeg.c.

#define EOI   0xd9

Definition at line 51 of file jpeg.c.

#define SOF0   0xc0

Definition at line 37 of file jpeg.c.

#define SOF1   0xc1

Definition at line 38 of file jpeg.c.

#define SOF10   0xca

Definition at line 45 of file jpeg.c.

#define SOF11   0xcb

Definition at line 46 of file jpeg.c.

#define SOF13   0xcd

Definition at line 47 of file jpeg.c.

#define SOF14   0xce

Definition at line 48 of file jpeg.c.

#define SOF15   0xcf

Definition at line 49 of file jpeg.c.

#define SOF2   0xc2

Definition at line 39 of file jpeg.c.

#define SOF3   0xc3

Definition at line 40 of file jpeg.c.

#define SOF5   0xc5

Definition at line 41 of file jpeg.c.

#define SOF6   0xc6

Definition at line 42 of file jpeg.c.

#define SOF7   0xc7

Definition at line 43 of file jpeg.c.

#define SOF9   0xc9

Definition at line 44 of file jpeg.c.

#define SOI   0xd8

Definition at line 50 of file jpeg.c.

#define SOS   0xda

Definition at line 52 of file jpeg.c.

#define verbose   0

Definition at line 35 of file jpeg.c.


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: