F.1. CODE LISTINGS FOR CHAPTER 1
359
} /* ends create_allocate_tiff_file */
/*********************************************
*
*
write_tiff_image(...
*
*
This function takes an array of shorts and
*
writes them into an existing tiff image file.
*
**********************************************/
write_tiff_image(image_file_name, array)
char
image_file_name[];
short
**array;
{
FILE *image_file;
int
bytes_written,
closed,
i,
position,
written;
float a;
long line_length,
offset;
struct tiff_header_struct image_header;
read_tiff_header(image_file_name, &image_header);
/***********************************************
*
*
Procedure:
*
Seek to the strip offset where the data begins.
*
Seek to the first line you want.
*
Loop over the lines you want to write.
*
Seek to the first element of the line.
*
Write the line.
Pdf open password - C# PDF Password Library: add, remove, edit PDF file password in C#.net, ASP.NET, MVC, WinForms, WPF
Help to Improve the Security of Your PDF Document by Setting Password
add copy protection pdf; pdf password remover
Pdf open password - VB.NET PDF Password Library: add, remove, edit PDF file password in vb.net, ASP.NET, MVC, WinForms, WPF
Help to Improve the Security of Your PDF Document by Setting Password
pdf password; convert password protected pdf to word
360
APPENDIX F. SOURCE CODE LISTINGS
*
Seek to the end of the data in that line.
*
************************************************/
image_file = fopen(image_file_name, "rb+");
position
= fseek(image_file,
image_header.strip_offset,
SEEK_SET);
for(i=0; i<image_header.image_length; i++){
bytes_written = write_line(image_file, array,
i, &image_header,
0, image_header.image_width);
} /* ends loop over i */
closed = fclose(image_file);
} /* ends write_tiff_image */
/*********************************************
*
*
write_line(...
*
*
This function takes an array of shorts,
*
extracts the numbers and puts them into
*
a buffer, then writes this buffer into a
*
tiff file on disk. The process depends on
*
the number of bits per pixel used in the
*
file (4 or 8).
*
**********************************************/
write_line(image_file, array, line_number,
image_header, ie, le)
FILE
*image_file;
int
ie, le, line_number;
short **array;
struct tiff_header_struct *image_header;
{
char
*buffer, first, second;
float
a, b;
Online Remove password from protected PDF file
Online Remove Password from Protected PDF file. Download Free Trial. Remove password from protected PDF file. Find your password-protected PDF and upload it.
a pdf password; annotate protected pdf
C# Create PDF from OpenOffice to convert odt, odp files to PDF in
C#.NET PDF - Create PDF from OpenOffice in C# with XDoc.PDF SDK. How to Use C#.NET Demo Code to Convert ODT to PDF in C#.NET Project.
copy protection pdf; adding a password to a pdf file
F.1. CODE LISTINGS FOR CHAPTER 1
361
int
bytes_written, i;
unsigned int bytes_to_write;
union
short_char_union scu;
buffer = (char *) malloc(image_header->image_width * sizeof(char ));
for(i=0; i<image_header->image_width; i++)
buffer[i] = ’\0’;
bytes_to_write = (le-ie)/
(8/image_header->bits_per_pixel);
for(i=0; i<bytes_to_write; i++){
/**********************************************
*
*
Use unions defined in cips.h to stuff shorts
*
into bytess.
*
**********************************************/
if(image_header->bits_per_pixel == 8){
scu.s_num = 0;
scu.s_num = array[line_number][i];
buffer[i] = scu.s_alpha[0];
} /* ends if bits_per_pixel == 8 */
if(image_header->bits_per_pixel == 4){
scu.s_num = 0;
scu.s_num = array[line_number][i*2];
first
= scu.s_alpha[0] << 4;
scu.s_num = 0;
scu.s_num = array[line_number][i*2];
second
= scu.s_alpha[0] & 0X000F;
buffer[i] = first | second;
} /* ends if bits_per_pixel == 4 */
} /* ends loop over i */
bytes_written = fwrite(buffer, 1, bytes_to_write,
image_file);
C# PDF Text Search Library: search text inside PDF file in C#.net
Open a document. SearchResult results = pdf.Search("RasterEdge", option); C#.NET PDF Demo Code: Search Text From One PDF Page in C#.NET.
copy text from protected pdf; add password to pdf reader
C#: How to Open a File from Database and Show It on HTML5 Doc
VB.NET Write: Add Image to PDF; VB.NET Protect: Add Password to PDF; VB.NET Form: extract value from Open a File from Database. File Formats. PDF. Word. Excel.
add password to pdf without acrobat; create password protected pdf
362
APPENDIX F. SOURCE CODE LISTINGS
free(buffer);
return(bytes_written);
} /* ends write_line */
/**********************************************
*
*
is_a_tiff(...
*
*
This function looks at a file to see if it
*
is a tiff file. First look at the file
*
extension. Next look at the first four
*
bytes of the header.
*
***********************************************/
int is_a_tiff(file_name)
char *file_name;
{
char
*cc;
char
buffer[4];
FILE
*fp;
int
ok
= 0,
result = 0;
cc = strstr(file_name, ".tif");
if(cc == NULL)
return(result);
fp = fopen(file_name, "rb");
fread(buffer, 1, 4, fp);
fclose(fp);
if(buffer[0] == 0x49 &&
buffer[1] == 0x49 &&
buffer[2] == 0x2a &&
buffer[3] == 0x00)
ok = 1;
C#: How to Open a File Inside the Server Using XDoc.HTML5 Viewer
VB.NET Write: Add Image to PDF; VB.NET Protect: Add Password to PDF; VB.NET Viewer, C#.NET convert image to PDF, C#.NET convert open office to PDF, C#.NET
add password to pdf file with reader; break pdf password online
C# PDF insert text Library: insert text into PDF content in C#.net
Open a document. String inputFilePath = Program.RootPath + "\\" 1.pdf"; PDFDocument doc = new PDFDocument(inputFilePath); // get a text manager from the
acrobat password protect pdf; creating password protected pdf
F.1. CODE LISTINGS FOR CHAPTER 1
363
if(buffer[0] == 0x4d &&
buffer[1] == 0x4d &&
buffer[2] == 0x00 &&
buffer[3] == 0x2a)
ok = 1;
if(ok == 0)
return(result);
result = 1;
return(result);
} /* ends is_a_tiff */
/*********************************************
*
*
equate_tiff_headers(...
*
*
This function sets the elements of the
*
destination header to the values of the
*
source header.
*
*********************************************/
equate_tiff_headers(src, dest)
struct tiff_header_struct *src, *dest;
{
dest->lsb
= src->lsb;
dest->bits_per_pixel = src->bits_per_pixel;
dest->image_length
= src->image_length;
dest->image_width
= src->image_width;
dest->strip_offset
= src->strip_offset;
} /* ends equate_tiff_headers */
/****************************************
*
*
extract_long_from_buffer(...
*
C# PDF Annotate Library: Draw, edit PDF annotation, markups in C#.
String inputFilePath = Program.RootPath + "\\" 2.pdf"; String outputFilePath = Program.RootPath + "\\" Annot_6.pdf"; // open a PDF file PDFDocument doc
pdf password online; pdf passwords
VB.NET PDF Print Library: Print PDF documents in vb.net, ASP.NET
Document Protect. Password: Set File Permissions. Password: Open Document. Edit Digital Signatures. Text. Add Text. Add Text Box. Drawing Markups. PDF Print. Work
pdf print protection; a pdf password online
364
APPENDIX F. SOURCE CODE LISTINGS
*
This takes a four byte long out of a
*
buffer of characters.
*
*
It is important to know the byte order
*
LSB or MSB.
*
****************************************/
extract_long_from_buffer(buffer, lsb, start, number)
char buffer[];
int
lsb, start;
long *number;
{
int i;
union long_char_union lcu;
if(lsb == 1){
lcu.l_alpha[0] = buffer[start+0];
lcu.l_alpha[1] = buffer[start+1];
lcu.l_alpha[2] = buffer[start+2];
lcu.l_alpha[3] = buffer[start+3];
} /* ends if lsb = 1 */
if(lsb == 0){
lcu.l_alpha[0] = buffer[start+3];
lcu.l_alpha[1] = buffer[start+2];
lcu.l_alpha[2] = buffer[start+1];
lcu.l_alpha[3] = buffer[start+0];
} /* ends if lsb = 0
*/
*number = lcu.l_num;
} /* ends extract_long_from_buffer */
/****************************************
*
*
extract_ulong_from_buffer(...
*
*
This takes a four byte unsigned long
*
out of a buffer of characters.
F.1. CODE LISTINGS FOR CHAPTER 1
365
*
*
It is important to know the byte order
*
LSB or MSB.
*
****************************************/
extract_ulong_from_buffer(buffer, lsb, start, number)
char buffer[];
int
lsb, start;
unsigned long *number;
{
int i;
union ulong_char_union lcu;
if(lsb == 1){
lcu.l_alpha[0] = buffer[start+0];
lcu.l_alpha[1] = buffer[start+1];
lcu.l_alpha[2] = buffer[start+2];
lcu.l_alpha[3] = buffer[start+3];
} /* ends if lsb = 1 */
if(lsb == 0){
lcu.l_alpha[0] = buffer[start+3];
lcu.l_alpha[1] = buffer[start+2];
lcu.l_alpha[2] = buffer[start+1];
lcu.l_alpha[3] = buffer[start+0];
} /* ends if lsb = 0
*/
*number = lcu.l_num;
} /* ends extract_ulong_from_buffer */
/****************************************
*
*
extract_short_from_buffer(...
*
*
This takes a two byte short out of a
*
buffer of characters.
*
*
It is important to know the byte order
*
LSB or MSB.
*
366
APPENDIX F. SOURCE CODE LISTINGS
****************************************/
extract_short_from_buffer(buffer, lsb, start, number)
char buffer[];
int
lsb, start;
short *number;
{
int i;
union short_char_union lcu;
if(lsb == 1){
lcu.s_alpha[0] = buffer[start+0];
lcu.s_alpha[1] = buffer[start+1];
} /* ends if lsb = 1 */
if(lsb == 0){
lcu.s_alpha[0] = buffer[start+1];
lcu.s_alpha[1] = buffer[start+0];
} /* ends if lsb = 0
*/
*number = lcu.s_num;
} /* ends extract_short_from_buffer */
/****************************************
*
*
extract_ushort_from_buffer(...
*
*
This takes a two byte unsiged short
*
out of a buffer of characters.
*
*
It is important to know the byte order
*
LSB or MSB.
*
****************************************/
extract_ushort_from_buffer(buffer, lsb, start, number)
char buffer[];
int
lsb, start;
F.1. CODE LISTINGS FOR CHAPTER 1
367
unsigned short *number;
{
int i;
union ushort_char_union lcu;
if(lsb == 1){
lcu.s_alpha[0] = buffer[start+0];
lcu.s_alpha[1] = buffer[start+1];
} /* ends if lsb = 1 */
if(lsb == 0){
lcu.s_alpha[0] = buffer[start+1];
lcu.s_alpha[1] = buffer[start+0];
} /* ends if lsb = 0
*/
*number = lcu.s_num;
} /* ends extract_ushort_from_buffer */
/***************************************
*
*
insert_short_into_buffer(...
*
*
This inserts a two byte short into a
*
buffer of characters. It does this
*
is LSB order.
*
***************************************/
insert_short_into_buffer(buffer, start, number)
char buffer[];
int
start;
short number;
{
union short_char_union lsu;
lsu.s_num
= number;
buffer[start+0] = lsu.s_alpha[0];
buffer[start+1] = lsu.s_alpha[1];
368
APPENDIX F. SOURCE CODE LISTINGS
} /* ends insert_short_into_buffer */
/***************************************
*
*
insert_ushort_into_buffer(...
*
*
This inserts a two byte unsigned
*
short into a buffer of characters.
*
It does this is LSB order.
*
***************************************/
insert_ushort_into_buffer(buffer, start, number)
char buffer[];
int
start;
unsigned short number;
{
union ushort_char_union lsu;
lsu.s_num
= number;
buffer[start+0] = lsu.s_alpha[0];
buffer[start+1] = lsu.s_alpha[1];
} /* ends insert_short_into_buffer */
/***************************************
*
*
insert_long_into_buffer(...
*
*
This inserts a four byte long into a
*
buffer of characters. It does this
*
is LSB order.
*
***************************************/
Documents you may be interested
Documents you may be interested