now use C99 stdint.h and stdbool.h
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,6 +1,6 @@
|
|||||||
# t2p: build a PDF file out of one or more TIFF Class F Group 4 files
|
# t2p: build a PDF file out of one or more TIFF Class F Group 4 files
|
||||||
# Makefile
|
# Makefile
|
||||||
# $Id: Makefile,v 1.9 2002/01/30 00:55:53 eric Exp $
|
# $Id: Makefile,v 1.10 2002/08/25 22:03:55 eric Exp $
|
||||||
# Copyright 2001 Eric Smith <eric@brouhaha.com>
|
# Copyright 2001 Eric Smith <eric@brouhaha.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@@ -25,7 +25,7 @@ YACC = bison
|
|||||||
YFLAGS = -d -v
|
YFLAGS = -d -v
|
||||||
|
|
||||||
SRCS = bitblt.c bitblt_test.c t2p.c semantics.c
|
SRCS = bitblt.c bitblt_test.c t2p.c semantics.c
|
||||||
HDRS = type.h bitblt.h t2p.h semantics.h
|
HDRS = bitblt.h t2p.h semantics.h
|
||||||
MISC = Makefile scanner.l parser.y
|
MISC = Makefile scanner.l parser.y
|
||||||
|
|
||||||
TARGETS = t2p bitblt_test
|
TARGETS = t2p bitblt_test
|
||||||
|
|||||||
49
bitblt.c
49
bitblt.c
@@ -1,16 +1,17 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "type.h"
|
|
||||||
#include "bitblt.h"
|
#include "bitblt.h"
|
||||||
|
|
||||||
|
|
||||||
#define DIV_ROUND_UP(count,pow2) (((count) - 1) / (pow2) + 1)
|
#define DIV_ROUND_UP(count,pow2) (((count) - 1) / (pow2) + 1)
|
||||||
|
|
||||||
|
|
||||||
static const u8 bit_reverse_byte [0x100] =
|
static const uint8_t bit_reverse_byte [0x100] =
|
||||||
{
|
{
|
||||||
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
|
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
|
||||||
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
|
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
|
||||||
@@ -47,7 +48,7 @@ static const u8 bit_reverse_byte [0x100] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void reverse_bits (u8 *p, int byte_count)
|
void reverse_bits (uint8_t *p, int byte_count)
|
||||||
{
|
{
|
||||||
while (byte_count--)
|
while (byte_count--)
|
||||||
{
|
{
|
||||||
@@ -69,7 +70,7 @@ static word_type bit_reverse_word (word_type d)
|
|||||||
static word_type *temp_buffer;
|
static word_type *temp_buffer;
|
||||||
static word_type temp_buffer_size;
|
static word_type temp_buffer_size;
|
||||||
|
|
||||||
static void realloc_temp_buffer (u32 size)
|
static void realloc_temp_buffer (uint32_t size)
|
||||||
{
|
{
|
||||||
if (size <= temp_buffer_size)
|
if (size <= temp_buffer_size)
|
||||||
return;
|
return;
|
||||||
@@ -121,8 +122,8 @@ static inline word_type pixel_range_mask (int left, int right)
|
|||||||
Bitmap *create_bitmap (Rect *rect)
|
Bitmap *create_bitmap (Rect *rect)
|
||||||
{
|
{
|
||||||
Bitmap *bitmap;
|
Bitmap *bitmap;
|
||||||
u32 width = rect_width (rect);
|
uint32_t width = rect_width (rect);
|
||||||
u32 height = rect_height (rect);
|
uint32_t height = rect_height (rect);
|
||||||
|
|
||||||
if ((width <= 0) || (height <= 0))
|
if ((width <= 0) || (height <= 0))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@@ -147,7 +148,7 @@ void free_bitmap (Bitmap *bitmap)
|
|||||||
free (bitmap);
|
free (bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean get_pixel (Bitmap *bitmap, Point coord)
|
bool get_pixel (Bitmap *bitmap, Point coord)
|
||||||
{
|
{
|
||||||
word_type *p;
|
word_type *p;
|
||||||
int w,b;
|
int w,b;
|
||||||
@@ -165,7 +166,7 @@ boolean get_pixel (Bitmap *bitmap, Point coord)
|
|||||||
return (((*p) & pixel_mask (b)) != 0);
|
return (((*p) & pixel_mask (b)) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_pixel (Bitmap *bitmap, Point coord, boolean value)
|
void set_pixel (Bitmap *bitmap, Point coord, bool value)
|
||||||
{
|
{
|
||||||
word_type *p;
|
word_type *p;
|
||||||
int w,b;
|
int w,b;
|
||||||
@@ -189,7 +190,7 @@ void set_pixel (Bitmap *bitmap, Point coord, boolean value)
|
|||||||
|
|
||||||
/* modifies rect1 to be the intersection of rect1 and rect2;
|
/* modifies rect1 to be the intersection of rect1 and rect2;
|
||||||
returns true if intersection is non-null */
|
returns true if intersection is non-null */
|
||||||
static boolean clip_rect (Rect *rect1, Rect *rect2)
|
static bool clip_rect (Rect *rect1, Rect *rect2)
|
||||||
{
|
{
|
||||||
if (rect1->min.y > rect2->max.y)
|
if (rect1->min.y > rect2->max.y)
|
||||||
goto empty;
|
goto empty;
|
||||||
@@ -223,12 +224,12 @@ static boolean clip_rect (Rect *rect1, Rect *rect2)
|
|||||||
static void blt_background (Bitmap *dest_bitmap,
|
static void blt_background (Bitmap *dest_bitmap,
|
||||||
Rect dest_rect)
|
Rect dest_rect)
|
||||||
{
|
{
|
||||||
u32 y;
|
uint32_t y;
|
||||||
word_type *rp;
|
word_type *rp;
|
||||||
u32 left_bit, left_word;
|
uint32_t left_bit, left_word;
|
||||||
u32 right_bit, right_word;
|
uint32_t right_bit, right_word;
|
||||||
word_type left_mask, right_mask;
|
word_type left_mask, right_mask;
|
||||||
s32 word_count;
|
int32_t word_count;
|
||||||
|
|
||||||
/* This function requires a non-null dest rect */
|
/* This function requires a non-null dest rect */
|
||||||
assert (dest_rect.min.x < dest_rect.max.x);
|
assert (dest_rect.min.x < dest_rect.max.x);
|
||||||
@@ -289,7 +290,7 @@ static void blt_background (Bitmap *dest_bitmap,
|
|||||||
/* use Duff's Device for the full words */
|
/* use Duff's Device for the full words */
|
||||||
if (word_count)
|
if (word_count)
|
||||||
{
|
{
|
||||||
s32 i = word_count;
|
int32_t i = word_count;
|
||||||
switch (i % 8)
|
switch (i % 8)
|
||||||
{
|
{
|
||||||
while (i > 0)
|
while (i > 0)
|
||||||
@@ -323,7 +324,7 @@ static void blt (Bitmap *src_bitmap,
|
|||||||
Bitmap *dest_bitmap,
|
Bitmap *dest_bitmap,
|
||||||
Rect *dest_rect)
|
Rect *dest_rect)
|
||||||
{
|
{
|
||||||
s32 y;
|
int32_t y;
|
||||||
word_type *rp;
|
word_type *rp;
|
||||||
|
|
||||||
/* This function requires a non-null src rect */
|
/* This function requires a non-null src rect */
|
||||||
@@ -402,18 +403,18 @@ Bitmap *bitblt (Bitmap *src_bitmap,
|
|||||||
{
|
{
|
||||||
Rect sr, dr; /* src and dest rects, clipped to visible portion of
|
Rect sr, dr; /* src and dest rects, clipped to visible portion of
|
||||||
dest rect */
|
dest rect */
|
||||||
u32 drw, drh; /* dest rect width, height - gets adjusted */
|
uint32_t drw, drh; /* dest rect width, height - gets adjusted */
|
||||||
Point src_point, dest_point;
|
Point src_point, dest_point;
|
||||||
|
|
||||||
/* dest coordinates: */
|
/* dest coordinates: */
|
||||||
u32 x0, x1, x2, x3;
|
uint32_t x0, x1, x2, x3;
|
||||||
u32 y0, y1, y2, y3;
|
uint32_t y0, y1, y2, y3;
|
||||||
|
|
||||||
{
|
{
|
||||||
sr = * src_rect;
|
sr = * src_rect;
|
||||||
|
|
||||||
u32 srw = rect_width (& sr);
|
uint32_t srw = rect_width (& sr);
|
||||||
u32 srh = rect_height (& sr);
|
uint32_t srh = rect_height (& sr);
|
||||||
|
|
||||||
if ((srw < 0) || (srh < 0))
|
if ((srw < 0) || (srh < 0))
|
||||||
goto done; /* the source rect is empty! */
|
goto done; /* the source rect is empty! */
|
||||||
@@ -595,7 +596,7 @@ Bitmap *bitblt (Bitmap *src_bitmap,
|
|||||||
src_point.x < src_rect->max.x;
|
src_point.x < src_rect->max.x;
|
||||||
src_point.x++)
|
src_point.x++)
|
||||||
{
|
{
|
||||||
boolean a;
|
bool a;
|
||||||
|
|
||||||
dest_point.x = dest_min->x + src_point.x - src_rect->min.x;
|
dest_point.x = dest_min->x + src_point.x - src_rect->min.x;
|
||||||
|
|
||||||
@@ -616,7 +617,7 @@ Bitmap *bitblt (Bitmap *src_bitmap,
|
|||||||
src_point.x < src_rect->max.x;
|
src_point.x < src_rect->max.x;
|
||||||
src_point.x++)
|
src_point.x++)
|
||||||
{
|
{
|
||||||
boolean a, b, c;
|
bool a, b, c;
|
||||||
|
|
||||||
dest_point.x = dest_min->x + src_point.x - src_rect->min.x;
|
dest_point.x = dest_min->x + src_point.x - src_rect->min.x;
|
||||||
|
|
||||||
@@ -639,7 +640,7 @@ void flip_h (Bitmap *src)
|
|||||||
word_type *rp; /* row pointer */
|
word_type *rp; /* row pointer */
|
||||||
word_type *p1; /* work src ptr */
|
word_type *p1; /* work src ptr */
|
||||||
word_type *p2; /* work dest ptr */
|
word_type *p2; /* work dest ptr */
|
||||||
s32 y;
|
int32_t y;
|
||||||
int shift1, shift2;
|
int shift1, shift2;
|
||||||
|
|
||||||
realloc_temp_buffer ((src->row_words + 1) * sizeof (word_type));
|
realloc_temp_buffer ((src->row_words + 1) * sizeof (word_type));
|
||||||
@@ -713,7 +714,7 @@ void rot_180 (Bitmap *src) /* combination of flip_h and flip_v */
|
|||||||
/* "in-place" transformations - will allocate new memory and free old */
|
/* "in-place" transformations - will allocate new memory and free old */
|
||||||
void transpose (Bitmap *src)
|
void transpose (Bitmap *src)
|
||||||
{
|
{
|
||||||
u32 new_row_words = DIV_ROUND_UP (rect_height (& src->rect), 32);
|
uint32_t new_row_words = DIV_ROUND_UP (rect_height (& src->rect), 32);
|
||||||
word_type *new_bits;
|
word_type *new_bits;
|
||||||
|
|
||||||
new_bits = calloc (1, new_row_words * rect_width (& src->rect) * sizeof (word_type));
|
new_bits = calloc (1, new_row_words * rect_width (& src->rect) * sizeof (word_type));
|
||||||
|
|||||||
18
bitblt.h
18
bitblt.h
@@ -1,7 +1,7 @@
|
|||||||
typedef struct Point
|
typedef struct Point
|
||||||
{
|
{
|
||||||
s32 x;
|
int32_t x;
|
||||||
s32 y;
|
int32_t y;
|
||||||
} Point;
|
} Point;
|
||||||
|
|
||||||
typedef struct Rect
|
typedef struct Rect
|
||||||
@@ -10,18 +10,18 @@ typedef struct Rect
|
|||||||
Point max;
|
Point max;
|
||||||
} Rect;
|
} Rect;
|
||||||
|
|
||||||
static inline s32 rect_width (Rect *r)
|
static inline int32_t rect_width (Rect *r)
|
||||||
{
|
{
|
||||||
return (r->max.x - r->min.x);
|
return (r->max.x - r->min.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline s32 rect_height (Rect *r)
|
static inline int32_t rect_height (Rect *r)
|
||||||
{
|
{
|
||||||
return (r->max.y - r->min.y);
|
return (r->max.y - r->min.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef u32 word_type;
|
typedef uint32_t word_type;
|
||||||
#define BITS_PER_WORD (8 * sizeof (word_type))
|
#define BITS_PER_WORD (8 * sizeof (word_type))
|
||||||
#define ALL_ONES (~ 0U)
|
#define ALL_ONES (~ 0U)
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ typedef struct Bitmap
|
|||||||
{
|
{
|
||||||
word_type *bits;
|
word_type *bits;
|
||||||
Rect rect;
|
Rect rect;
|
||||||
u32 row_words;
|
uint32_t row_words;
|
||||||
} Bitmap;
|
} Bitmap;
|
||||||
|
|
||||||
|
|
||||||
@@ -43,8 +43,8 @@ typedef struct Bitmap
|
|||||||
Bitmap *create_bitmap (Rect *rect);
|
Bitmap *create_bitmap (Rect *rect);
|
||||||
void free_bitmap (Bitmap *bitmap);
|
void free_bitmap (Bitmap *bitmap);
|
||||||
|
|
||||||
boolean get_pixel (Bitmap *bitmap, Point coord);
|
bool get_pixel (Bitmap *bitmap, Point coord);
|
||||||
void set_pixel (Bitmap *bitmap, Point coord, boolean value);
|
void set_pixel (Bitmap *bitmap, Point coord, bool value);
|
||||||
|
|
||||||
|
|
||||||
Bitmap *bitblt (Bitmap *src_bitmap,
|
Bitmap *bitblt (Bitmap *src_bitmap,
|
||||||
@@ -68,4 +68,4 @@ void rot_90 (Bitmap *src); /* transpose + flip_h */
|
|||||||
void rot_270 (Bitmap *src); /* transpose + flip_v */
|
void rot_270 (Bitmap *src); /* transpose + flip_v */
|
||||||
|
|
||||||
|
|
||||||
void reverse_bits (u8 *p, int byte_count);
|
void reverse_bits (uint8_t *p, int byte_count);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "type.h"
|
|
||||||
#include "bitblt.h"
|
#include "bitblt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
5
parser.y
5
parser.y
@@ -1,6 +1,7 @@
|
|||||||
%{
|
%{
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "type.h"
|
|
||||||
#include "semantics.h"
|
#include "semantics.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -186,7 +187,7 @@ pdf_file_attributes:
|
|||||||
|
|
||||||
output_file_clause:
|
output_file_clause:
|
||||||
FILE_KEYWORD STRING { output_set_file ($2); }
|
FILE_KEYWORD STRING { output_set_file ($2); }
|
||||||
pdf_file_attributes ';'
|
pdf_file_attributes ';' ;
|
||||||
|
|
||||||
label_clause:
|
label_clause:
|
||||||
LABEL ';' { page_label_t label = { NULL, '\0' }; output_set_page_label (label); }
|
LABEL ';' { page_label_t label = { NULL, '\0' }; output_set_page_label (label); }
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
$Id: scanner.l,v 1.15 2002/01/02 02:17:24 eric Exp $
|
$Id: scanner.l,v 1.16 2002/08/25 22:02:31 eric Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%option case-insensitive
|
%option case-insensitive
|
||||||
%option noyywrap
|
%option noyywrap
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "type.h"
|
|
||||||
#include "semantics.h"
|
#include "semantics.h"
|
||||||
#include "parser.tab.h"
|
#include "parser.tab.h"
|
||||||
|
|
||||||
|
|||||||
31
semantics.c
31
semantics.c
@@ -1,8 +1,9 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "type.h"
|
|
||||||
#include "semantics.h"
|
#include "semantics.h"
|
||||||
#include "parser.tab.h"
|
#include "parser.tab.h"
|
||||||
#include "t2p.h"
|
#include "t2p.h"
|
||||||
@@ -10,13 +11,13 @@
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
boolean has_page_size;
|
bool has_page_size;
|
||||||
page_size_t page_size;
|
page_size_t page_size;
|
||||||
|
|
||||||
boolean has_rotation;
|
bool has_rotation;
|
||||||
int rotation;
|
int rotation;
|
||||||
|
|
||||||
boolean has_crop;
|
bool has_crop;
|
||||||
crop_t crop;
|
crop_t crop;
|
||||||
} input_modifiers_t;
|
} input_modifiers_t;
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ typedef struct output_context_t
|
|||||||
bookmark_t *first_bookmark;
|
bookmark_t *first_bookmark;
|
||||||
bookmark_t *last_bookmark;
|
bookmark_t *last_bookmark;
|
||||||
|
|
||||||
boolean has_page_label;
|
bool has_page_label;
|
||||||
page_label_t page_label;
|
page_label_t page_label;
|
||||||
} output_context_t;
|
} output_context_t;
|
||||||
|
|
||||||
@@ -432,9 +433,9 @@ static char *get_input_file (input_context_t *context)
|
|||||||
exit (2);
|
exit (2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean get_input_rotation (input_context_t *context,
|
static bool get_input_rotation (input_context_t *context,
|
||||||
input_modifier_type_t type,
|
input_modifier_type_t type,
|
||||||
int *rotation)
|
int *rotation)
|
||||||
{
|
{
|
||||||
for (; context; context = context->parent)
|
for (; context; context = context->parent)
|
||||||
{
|
{
|
||||||
@@ -452,9 +453,9 @@ static boolean get_input_rotation (input_context_t *context,
|
|||||||
return (0); /* default */
|
return (0); /* default */
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean get_input_page_size (input_context_t *context,
|
static bool get_input_page_size (input_context_t *context,
|
||||||
input_modifier_type_t type,
|
input_modifier_type_t type,
|
||||||
page_size_t *page_size)
|
page_size_t *page_size)
|
||||||
{
|
{
|
||||||
for (; context; context = context->parent)
|
for (; context; context = context->parent)
|
||||||
{
|
{
|
||||||
@@ -510,7 +511,7 @@ void dump_input_tree (void)
|
|||||||
for (i = image->range.first; i <= image->range.last; i++)
|
for (i = image->range.first; i <= image->range.last; i++)
|
||||||
{
|
{
|
||||||
input_modifier_type_t parity = (i % 2) ? INPUT_MODIFIER_ODD : INPUT_MODIFIER_EVEN;
|
input_modifier_type_t parity = (i % 2) ? INPUT_MODIFIER_ODD : INPUT_MODIFIER_EVEN;
|
||||||
boolean has_rotation, has_page_size;
|
bool has_rotation, has_page_size;
|
||||||
int rotation;
|
int rotation;
|
||||||
page_size_t page_size;
|
page_size_t page_size;
|
||||||
|
|
||||||
@@ -571,9 +572,9 @@ static inline int range_count (range_t range)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean parse_spec_file (char *fn)
|
bool parse_spec_file (char *fn)
|
||||||
{
|
{
|
||||||
boolean result = 0;
|
bool result = 0;
|
||||||
|
|
||||||
yyin = fopen (fn, "r");
|
yyin = fopen (fn, "r");
|
||||||
if (! yyin)
|
if (! yyin)
|
||||||
@@ -617,7 +618,7 @@ boolean parse_spec_file (char *fn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean process_specs (void)
|
bool process_specs (void)
|
||||||
{
|
{
|
||||||
input_image_t *image = NULL;
|
input_image_t *image = NULL;
|
||||||
output_page_t *page = NULL;
|
output_page_t *page = NULL;
|
||||||
|
|||||||
@@ -72,5 +72,5 @@ void output_pages (range_t range);
|
|||||||
|
|
||||||
|
|
||||||
/* functions to be called from main program: */
|
/* functions to be called from main program: */
|
||||||
boolean parse_spec_file (char *fn);
|
bool parse_spec_file (char *fn);
|
||||||
boolean process_specs (void);
|
bool process_specs (void);
|
||||||
|
|||||||
39
t2p.c
39
t2p.c
@@ -4,7 +4,7 @@
|
|||||||
* will be compressed using ITU-T T.6 (G4) fax encoding.
|
* will be compressed using ITU-T T.6 (G4) fax encoding.
|
||||||
*
|
*
|
||||||
* Main program
|
* Main program
|
||||||
* $Id: t2p.c,v 1.18 2002/08/25 21:43:49 eric Exp $
|
* $Id: t2p.c,v 1.19 2002/08/25 22:02:31 eric Exp $
|
||||||
* Copyright 2001 Eric Smith <eric@brouhaha.com>
|
* Copyright 2001 Eric Smith <eric@brouhaha.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -23,6 +23,8 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA */
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA */
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -33,7 +35,6 @@
|
|||||||
#include <panda/functions.h>
|
#include <panda/functions.h>
|
||||||
#include <panda/constants.h>
|
#include <panda/constants.h>
|
||||||
|
|
||||||
#include "type.h"
|
|
||||||
#include "bitblt.h"
|
#include "bitblt.h"
|
||||||
#include "semantics.h"
|
#include "semantics.h"
|
||||||
#include "parser.tab.h"
|
#include "parser.tab.h"
|
||||||
@@ -62,7 +63,7 @@ output_file_t *out;
|
|||||||
/* panda_pdf *out; */
|
/* panda_pdf *out; */
|
||||||
|
|
||||||
|
|
||||||
boolean close_tiff_input_file (void)
|
bool close_tiff_input_file (void)
|
||||||
{
|
{
|
||||||
if (in)
|
if (in)
|
||||||
{
|
{
|
||||||
@@ -74,7 +75,7 @@ boolean close_tiff_input_file (void)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean open_tiff_input_file (char *name)
|
bool open_tiff_input_file (char *name)
|
||||||
{
|
{
|
||||||
if (in)
|
if (in)
|
||||||
{
|
{
|
||||||
@@ -99,7 +100,7 @@ boolean open_tiff_input_file (char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean close_pdf_output_files (void)
|
bool close_pdf_output_files (void)
|
||||||
{
|
{
|
||||||
output_file_t *o, *n;
|
output_file_t *o, *n;
|
||||||
|
|
||||||
@@ -115,8 +116,8 @@ boolean close_pdf_output_files (void)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean open_pdf_output_file (char *name,
|
bool open_pdf_output_file (char *name,
|
||||||
pdf_file_attributes_t *attributes)
|
pdf_file_attributes_t *attributes)
|
||||||
{
|
{
|
||||||
output_file_t *o;
|
output_file_t *o;
|
||||||
|
|
||||||
@@ -225,23 +226,23 @@ static void rotate_bitmap (Bitmap *src,
|
|||||||
|
|
||||||
#define SWAP(type,a,b) do { type temp; temp = a; a = b; b = temp; } while (0)
|
#define SWAP(type,a,b) do { type temp; temp = a; a = b; b = temp; } while (0)
|
||||||
|
|
||||||
boolean process_page (int image, /* range 1 .. n */
|
bool process_page (int image, /* range 1 .. n */
|
||||||
input_attributes_t input_attributes,
|
input_attributes_t input_attributes,
|
||||||
bookmark_t *bookmarks)
|
bookmark_t *bookmarks)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
u32 image_length, image_width;
|
uint32_t image_length, image_width;
|
||||||
u32 dest_image_length, dest_image_width;
|
uint32_t dest_image_length, dest_image_width;
|
||||||
#ifdef CHECK_DEPTH
|
#ifdef CHECK_DEPTH
|
||||||
u32 image_depth;
|
uint32_t image_depth;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u16 samples_per_pixel;
|
uint16_t samples_per_pixel;
|
||||||
u16 bits_per_sample;
|
uint16_t bits_per_sample;
|
||||||
u16 planar_config;
|
uint16_t planar_config;
|
||||||
|
|
||||||
u16 resolution_unit;
|
uint16_t resolution_unit;
|
||||||
float x_resolution, y_resolution;
|
float x_resolution, y_resolution;
|
||||||
float dest_x_resolution, dest_y_resolution;
|
float dest_x_resolution, dest_y_resolution;
|
||||||
|
|
||||||
@@ -381,7 +382,7 @@ boolean process_page (int image, /* range 1 .. n */
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TIFF_REVERSE_BITS
|
#ifdef TIFF_REVERSE_BITS
|
||||||
reverse_bits ((u8 *) bitmap->bits,
|
reverse_bits ((uint8_t *) bitmap->bits,
|
||||||
image_length * bitmap->row_words * sizeof (word_type));
|
image_length * bitmap->row_words * sizeof (word_type));
|
||||||
#endif /* TIFF_REVERSE_BITS */
|
#endif /* TIFF_REVERSE_BITS */
|
||||||
|
|
||||||
@@ -424,7 +425,7 @@ boolean process_page (int image, /* range 1 .. n */
|
|||||||
TIFFSetField (tiff_temp, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
|
TIFFSetField (tiff_temp, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
|
||||||
|
|
||||||
#ifdef TIFF_REVERSE_BITS
|
#ifdef TIFF_REVERSE_BITS
|
||||||
reverse_bits ((u8 *) bitmap->bits,
|
reverse_bits ((uint8_t *) bitmap->bits,
|
||||||
image_length * bitmap->row_words * sizeof (word_type));
|
image_length * bitmap->row_words * sizeof (word_type));
|
||||||
#endif /* TIFF_REVERSE_BITS */
|
#endif /* TIFF_REVERSE_BITS */
|
||||||
|
|
||||||
|
|||||||
22
t2p.h
22
t2p.h
@@ -1,21 +1,21 @@
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
boolean has_resolution;
|
bool has_resolution;
|
||||||
double x_resolution;
|
double x_resolution;
|
||||||
double y_resolution;
|
double y_resolution;
|
||||||
|
|
||||||
boolean has_page_size;
|
bool has_page_size;
|
||||||
page_size_t page_size;
|
page_size_t page_size;
|
||||||
|
|
||||||
boolean has_rotation;
|
bool has_rotation;
|
||||||
int rotation;
|
int rotation;
|
||||||
|
|
||||||
boolean has_crop;
|
bool has_crop;
|
||||||
crop_t crop;
|
crop_t crop;
|
||||||
} input_attributes_t;
|
} input_attributes_t;
|
||||||
|
|
||||||
boolean open_tiff_input_file (char *name);
|
bool open_tiff_input_file (char *name);
|
||||||
boolean close_tiff_input_file (void);
|
bool close_tiff_input_file (void);
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -27,8 +27,8 @@ typedef struct
|
|||||||
char *keywords;
|
char *keywords;
|
||||||
} pdf_file_attributes_t;
|
} pdf_file_attributes_t;
|
||||||
|
|
||||||
boolean open_pdf_output_file (char *name,
|
bool open_pdf_output_file (char *name,
|
||||||
pdf_file_attributes_t *attributes);
|
pdf_file_attributes_t *attributes);
|
||||||
|
|
||||||
|
|
||||||
void process_page_numbers (int page_index,
|
void process_page_numbers (int page_index,
|
||||||
@@ -36,6 +36,6 @@ void process_page_numbers (int page_index,
|
|||||||
int base,
|
int base,
|
||||||
page_label_t *page_label);
|
page_label_t *page_label);
|
||||||
|
|
||||||
boolean process_page (int image, /* range 1 .. n */
|
bool process_page (int image, /* range 1 .. n */
|
||||||
input_attributes_t input_attributes,
|
input_attributes_t input_attributes,
|
||||||
bookmark_t *bookmarks);
|
bookmark_t *bookmarks);
|
||||||
|
|||||||
39
tumble.c
39
tumble.c
@@ -4,7 +4,7 @@
|
|||||||
* will be compressed using ITU-T T.6 (G4) fax encoding.
|
* will be compressed using ITU-T T.6 (G4) fax encoding.
|
||||||
*
|
*
|
||||||
* Main program
|
* Main program
|
||||||
* $Id: tumble.c,v 1.18 2002/08/25 21:43:49 eric Exp $
|
* $Id: tumble.c,v 1.19 2002/08/25 22:02:31 eric Exp $
|
||||||
* Copyright 2001 Eric Smith <eric@brouhaha.com>
|
* Copyright 2001 Eric Smith <eric@brouhaha.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -23,6 +23,8 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA */
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA */
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -33,7 +35,6 @@
|
|||||||
#include <panda/functions.h>
|
#include <panda/functions.h>
|
||||||
#include <panda/constants.h>
|
#include <panda/constants.h>
|
||||||
|
|
||||||
#include "type.h"
|
|
||||||
#include "bitblt.h"
|
#include "bitblt.h"
|
||||||
#include "semantics.h"
|
#include "semantics.h"
|
||||||
#include "parser.tab.h"
|
#include "parser.tab.h"
|
||||||
@@ -62,7 +63,7 @@ output_file_t *out;
|
|||||||
/* panda_pdf *out; */
|
/* panda_pdf *out; */
|
||||||
|
|
||||||
|
|
||||||
boolean close_tiff_input_file (void)
|
bool close_tiff_input_file (void)
|
||||||
{
|
{
|
||||||
if (in)
|
if (in)
|
||||||
{
|
{
|
||||||
@@ -74,7 +75,7 @@ boolean close_tiff_input_file (void)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean open_tiff_input_file (char *name)
|
bool open_tiff_input_file (char *name)
|
||||||
{
|
{
|
||||||
if (in)
|
if (in)
|
||||||
{
|
{
|
||||||
@@ -99,7 +100,7 @@ boolean open_tiff_input_file (char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean close_pdf_output_files (void)
|
bool close_pdf_output_files (void)
|
||||||
{
|
{
|
||||||
output_file_t *o, *n;
|
output_file_t *o, *n;
|
||||||
|
|
||||||
@@ -115,8 +116,8 @@ boolean close_pdf_output_files (void)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean open_pdf_output_file (char *name,
|
bool open_pdf_output_file (char *name,
|
||||||
pdf_file_attributes_t *attributes)
|
pdf_file_attributes_t *attributes)
|
||||||
{
|
{
|
||||||
output_file_t *o;
|
output_file_t *o;
|
||||||
|
|
||||||
@@ -225,23 +226,23 @@ static void rotate_bitmap (Bitmap *src,
|
|||||||
|
|
||||||
#define SWAP(type,a,b) do { type temp; temp = a; a = b; b = temp; } while (0)
|
#define SWAP(type,a,b) do { type temp; temp = a; a = b; b = temp; } while (0)
|
||||||
|
|
||||||
boolean process_page (int image, /* range 1 .. n */
|
bool process_page (int image, /* range 1 .. n */
|
||||||
input_attributes_t input_attributes,
|
input_attributes_t input_attributes,
|
||||||
bookmark_t *bookmarks)
|
bookmark_t *bookmarks)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
u32 image_length, image_width;
|
uint32_t image_length, image_width;
|
||||||
u32 dest_image_length, dest_image_width;
|
uint32_t dest_image_length, dest_image_width;
|
||||||
#ifdef CHECK_DEPTH
|
#ifdef CHECK_DEPTH
|
||||||
u32 image_depth;
|
uint32_t image_depth;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u16 samples_per_pixel;
|
uint16_t samples_per_pixel;
|
||||||
u16 bits_per_sample;
|
uint16_t bits_per_sample;
|
||||||
u16 planar_config;
|
uint16_t planar_config;
|
||||||
|
|
||||||
u16 resolution_unit;
|
uint16_t resolution_unit;
|
||||||
float x_resolution, y_resolution;
|
float x_resolution, y_resolution;
|
||||||
float dest_x_resolution, dest_y_resolution;
|
float dest_x_resolution, dest_y_resolution;
|
||||||
|
|
||||||
@@ -381,7 +382,7 @@ boolean process_page (int image, /* range 1 .. n */
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TIFF_REVERSE_BITS
|
#ifdef TIFF_REVERSE_BITS
|
||||||
reverse_bits ((u8 *) bitmap->bits,
|
reverse_bits ((uint8_t *) bitmap->bits,
|
||||||
image_length * bitmap->row_words * sizeof (word_type));
|
image_length * bitmap->row_words * sizeof (word_type));
|
||||||
#endif /* TIFF_REVERSE_BITS */
|
#endif /* TIFF_REVERSE_BITS */
|
||||||
|
|
||||||
@@ -424,7 +425,7 @@ boolean process_page (int image, /* range 1 .. n */
|
|||||||
TIFFSetField (tiff_temp, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
|
TIFFSetField (tiff_temp, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
|
||||||
|
|
||||||
#ifdef TIFF_REVERSE_BITS
|
#ifdef TIFF_REVERSE_BITS
|
||||||
reverse_bits ((u8 *) bitmap->bits,
|
reverse_bits ((uint8_t *) bitmap->bits,
|
||||||
image_length * bitmap->row_words * sizeof (word_type));
|
image_length * bitmap->row_words * sizeof (word_type));
|
||||||
#endif /* TIFF_REVERSE_BITS */
|
#endif /* TIFF_REVERSE_BITS */
|
||||||
|
|
||||||
|
|||||||
22
tumble.h
22
tumble.h
@@ -1,21 +1,21 @@
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
boolean has_resolution;
|
bool has_resolution;
|
||||||
double x_resolution;
|
double x_resolution;
|
||||||
double y_resolution;
|
double y_resolution;
|
||||||
|
|
||||||
boolean has_page_size;
|
bool has_page_size;
|
||||||
page_size_t page_size;
|
page_size_t page_size;
|
||||||
|
|
||||||
boolean has_rotation;
|
bool has_rotation;
|
||||||
int rotation;
|
int rotation;
|
||||||
|
|
||||||
boolean has_crop;
|
bool has_crop;
|
||||||
crop_t crop;
|
crop_t crop;
|
||||||
} input_attributes_t;
|
} input_attributes_t;
|
||||||
|
|
||||||
boolean open_tiff_input_file (char *name);
|
bool open_tiff_input_file (char *name);
|
||||||
boolean close_tiff_input_file (void);
|
bool close_tiff_input_file (void);
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -27,8 +27,8 @@ typedef struct
|
|||||||
char *keywords;
|
char *keywords;
|
||||||
} pdf_file_attributes_t;
|
} pdf_file_attributes_t;
|
||||||
|
|
||||||
boolean open_pdf_output_file (char *name,
|
bool open_pdf_output_file (char *name,
|
||||||
pdf_file_attributes_t *attributes);
|
pdf_file_attributes_t *attributes);
|
||||||
|
|
||||||
|
|
||||||
void process_page_numbers (int page_index,
|
void process_page_numbers (int page_index,
|
||||||
@@ -36,6 +36,6 @@ void process_page_numbers (int page_index,
|
|||||||
int base,
|
int base,
|
||||||
page_label_t *page_label);
|
page_label_t *page_label);
|
||||||
|
|
||||||
boolean process_page (int image, /* range 1 .. n */
|
bool process_page (int image, /* range 1 .. n */
|
||||||
input_attributes_t input_attributes,
|
input_attributes_t input_attributes,
|
||||||
bookmark_t *bookmarks);
|
bookmark_t *bookmarks);
|
||||||
|
|||||||
Reference in New Issue
Block a user