F.1. CODE LISTINGS FOR CHAPTER 1
349
bytes_to_read = (le-ie)/
(8/image_header->bits_per_pixel);
bytes_read
= fread(buffer, 1, bytes_to_read,
image_file);
for(i=0; i<bytes_read; i++){
/*********************************************
*
*
Use unions defined in cips.h to stuff bytes
*
into shorts.
*
**********************************************/
if(image_header->bits_per_pixel == 8){
scu.s_num
= 0;
scu.s_alpha[0]
= buffer[i];
the_image[line_number][i] = scu.s_num;
} /* ends if bits_per_pixel == 8 */
if(image_header->bits_per_pixel == 4){
scu.s_num
= 0;
second
= buffer[i] & 0X000F;
scu.s_alpha[0]
= second;
the_image[line_number][i*2+1] = scu.s_num;
scu.s_num
= 0;
first
= buffer[i] >> 4;
first
= first & 0x000F;
scu.s_alpha[0]
= first;
the_image[line_number][i*2] = scu.s_num;
} /* ends if bits_per_pixel == 4 */
} /* ends loop over i */
free(buffer);
return(bytes_read);
} /* ends read_line */
Pdf image extractor online - Select, copy, paste PDF images in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support PDF Image Extraction from a Page, a Region on a Page, and PDF Document
how to extract images from pdf file; extract image from pdf using
Pdf image extractor online - VB.NET PDF Image Extract Library: Select, copy, paste PDF images in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support PDF Image Extraction from a Page, a Region on a Page, and PDF Document
extract photo from pdf; some pdf image extractor
350
APPENDIX F. SOURCE CODE LISTINGS
/**********************************************
*
*
create_tiff_file_if_needed(...
*
*
This function creates a tiff file on disk
*
if it does not exist. The out file is
*
patterned after the in file.
*
***********************************************/
create_tiff_file_if_needed(in_name, out_name, out_image)
char in_name[], out_name[];
short **out_image;
{
int
length, width;
struct tiff_header_struct image_header;
if(does_not_exist(out_name)){
printf("\n\n output file does not exist %s",
out_name);
read_tiff_header(in_name, &image_header);
create_allocate_tiff_file(out_name, &image_header);
printf("\nBFIN> Created %s", out_name);
} /* ends if does_not_exist */
} /* ends create_tiff_file_if_needed */
/**********************************************
*
*
create_alllocate_tiff_file(...
*
*
This function creates a file on disk that will be
*
large enough to hold a tiff image. The input
*
tiff_header_struct describes the desired tiff file.
*
This function writes the tiff header and then
*
writes a blank image array out to disk the proper
*
number of times. This has the effect of allocating
*
the correct number of bytes on the disk.
*
*
There will be 18 entries in the IFD.
VB.NET TIFF: TIFF Text Extractor SDK; Extract Text Content from
In this online tutorial, we will offer you information on Standalone VB.NET TIFF text extractor SDK that extracts control SDK into VB.NET image application by
some pdf image extract; extract text from pdf image
VB.NET PowerPoint: Extract & Collect PPT Slide(s) Using VB Sample
demo code using RasterEdge VB.NET PowerPoint extractor library toolkit. provide powerful & profession imaging controls, PDF document, image to pdf files and
extract image from pdf; how to extract text from pdf image file
F.1. CODE LISTINGS FOR CHAPTER 1
351
*
The image data will begin at byte 296.
*
I will use LSB first data.
*
I will have one strip for the entire image.
*
Black is zero.
*
The component values for the image are CHUNKY
*
(Planer configuration = 1).
*
***************************************************/
create_allocate_tiff_file(file_name,
image_header)
char
file_name[];
struct tiff_header_struct *image_header;
{
char buffer[12], *image_buffer, long_buffer[50];
FILE *image_file;
int
bytes_written,
i,
j,
l,
w;
long k;
/***************************************
*
*
Create the image file in binary mode
*
for both reading and writing.
*
****************************************/
image_file = fopen(file_name, "wb");
/***************************************
*
*
Write out the first 8 bytes of the
*
header. The meaning of the
*
bytes (HEX) is:
*
0-1 = 49 49 - LSB first
*
2-3 = 2A 00 - version #
*
4-7 = 08 00 00 00 - go to offset
*
8 for the first
VB.NET Word: Extract Word Pages, DOCX Page Extraction SDK
this VB.NET Word page extractor add-on can be also used to merge / split Word file, add / delete Word page, sort Word page order or insert image into Word page
how to extract images from pdf; how to extract a picture from a pdf
VB.NET TIFF: TIFF to Text (TXT) Converter SDK; Convert TIFF to
NET developers to interpret and decode TIFF image file. But different from TIFF text extractor add-on powerful & profession imaging controls, PDF document, tiff
extract images pdf; extract images from pdf file
352
APPENDIX F. SOURCE CODE LISTINGS
*
Image File
*
Directory
*
****************************************/
buffer[0] = 0x49;
buffer[1] = 0x49;
buffer[2] = 0x2A;
buffer[3] = 0x00;
buffer[4] = 0x08;
buffer[5] = 0x00;
buffer[6] = 0x00;
buffer[7] = 0x00;
bytes_written = fwrite(buffer, 1, 8, image_file);
printf("\n wrote %d bytes", bytes_written);
/***************************************
*
*
Write out the first 2 bytes of the
*
Image File Directory. These tell
*
the number of entries in the IFD.
*
****************************************/
buffer[0] = 0x12;
buffer[1] = 0x00;
bytes_written = fwrite(buffer, 1, 2, image_file);
printf("\n wrote %d bytes", bytes_written);
/***************************************
*
*
Write out the entries into the
*
Image File Directory.
*
****************************************/
/* New Subfile Type */
buffer[0] = 0xFE;
buffer[1] = 0x00;
buffer[2] = 0x03;
buffer[3] = 0x00;
C# Word: How to Extract Text from C# Word in .NET Project
you can rest assured because this Word text extractor preserves both to provide powerful & profession imaging controls, PDF document, image to pdf files and
extract images pdf acrobat; extract images from pdf acrobat
F.1. CODE LISTINGS FOR CHAPTER 1
353
buffer[4] = 0x01;
buffer[5] = 0x00;
buffer[6] = 0x00;
buffer[7] = 0x00;
buffer[8] = 0x00;
buffer[9] = 0x00;
buffer[10] = 0x00;
buffer[11] = 0x00;
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Subfile Type */
buffer[0] = 0xFF;
buffer[1] = 0x00;
buffer[2] = 0x03;
buffer[3] = 0x00;
buffer[4] = 0x01;
buffer[5] = 0x00;
buffer[6] = 0x00;
buffer[7] = 0x00;
buffer[8] = 0x01;
buffer[9] = 0x00;
buffer[10] = 0x00;
buffer[11] = 0x00;
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Image Width */
insert_short_into_buffer(buffer, 0, 256);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8,
image_header->image_width);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Image Length */
insert_short_into_buffer(buffer, 0, 257);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8,
image_header->image_length);
354
APPENDIX F. SOURCE CODE LISTINGS
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Bits Per Sample */
insert_short_into_buffer(buffer, 0, 258);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8,
image_header->bits_per_pixel);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Compression - None */
insert_short_into_buffer(buffer, 0, 259);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8, 1);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Photometric Interpretation */
/* set to 1 because BLACK is ZERO */
insert_short_into_buffer(buffer, 0, 262);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8, 1);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Strip Offset */
/* start after software name at 296 */
insert_short_into_buffer(buffer, 0, 273);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8, 296);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Samples per Pixel */
insert_short_into_buffer(buffer, 0, 277);
F.1. CODE LISTINGS FOR CHAPTER 1
355
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8, 1);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* clear buffer */
for(i=0; i<12; i++) buffer[i] = 0x00;
/* Rows Per Strip 1 strip for the entire image */
/* use 2E32 - 1, which is max */
insert_short_into_buffer(buffer, 0, 278);
insert_short_into_buffer(buffer, 2, 4);
insert_short_into_buffer(buffer, 4, 1);
insert_long_into_buffer(buffer, 8, 4294967295);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Strip Byte Counts */
/* this = image width times length */
insert_short_into_buffer(buffer, 0, 279);
insert_short_into_buffer(buffer, 2, 4);
insert_short_into_buffer(buffer, 4, 1);
insert_long_into_buffer(buffer, 8,
(long)(image_header->image_length *
image_header->image_width));
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Min Sample Value */
insert_short_into_buffer(buffer, 0, 280);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8, 0);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Max Sample Value */
insert_short_into_buffer(buffer, 0, 281);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
356
APPENDIX F. SOURCE CODE LISTINGS
if(image_header->bits_per_pixel == 8)
insert_short_into_buffer(buffer, 8, 255);
else
insert_short_into_buffer(buffer, 8, 15);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* X Resolution */
/* Store the 8 bytes for this value
starting at 230 */
insert_short_into_buffer(buffer, 0, 282);
insert_short_into_buffer(buffer, 2, 5);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8, 230);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Y Resolution */
/* Store the 8 bytes for this value
starting at 238 */
insert_short_into_buffer(buffer, 0, 283);
insert_short_into_buffer(buffer, 2, 5);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8, 238);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* clear buffer */
for(i=0; i<12; i++) buffer[i] = 0x00;
/* Planer Configuration */
/* chunky */
insert_short_into_buffer(buffer, 0, 284);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8, 1);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Resolution Unit */
F.1. CODE LISTINGS FOR CHAPTER 1
357
/* inches */
insert_short_into_buffer(buffer, 0, 296);
insert_short_into_buffer(buffer, 2, 3);
insert_short_into_buffer(buffer, 4, 1);
insert_short_into_buffer(buffer, 8, 2);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Software */
/* Put this a 246, 50 bytes */
insert_short_into_buffer(buffer, 0, 305);
insert_short_into_buffer(buffer, 2, 2);
insert_short_into_buffer(buffer, 4, 50);
insert_short_into_buffer(buffer, 8, 246);
bytes_written = fwrite(buffer, 1, 12, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Offset to next IFD (0 means no more IFD’s) */
for(i=0; i<12; i++) buffer[i] = 0x00;
bytes_written = fwrite(buffer, 1, 4, image_file);
printf("\n wrote %d bytes", bytes_written);
/* clear buffer */
for(i=0; i<12; i++) buffer[i] = 0x00;
/* Now store the X Resolution
first long is numerator
second long is denominator */
insert_long_into_buffer(buffer, 0, 300L);
insert_long_into_buffer(buffer, 4, 1L);
bytes_written = fwrite(buffer, 1, 8, image_file);
printf("\n wrote %d bytes", bytes_written);
/* Now store the Y Resolution
first long is numerator
second long is denominator */
insert_long_into_buffer(buffer, 0, 300L);
insert_long_into_buffer(buffer, 4, 1L);
bytes_written = fwrite(buffer, 1, 8, image_file);
printf("\n wrote %d bytes", bytes_written);
358
APPENDIX F. SOURCE CODE LISTINGS
/* Now store the software tag */
for(i=0; i<50; i++) long_buffer[i] = ’\0’;
strcpy(long_buffer,
"Dwayne Phillips C Image Processing System 1993");
long_buffer[46] = ’\0’;
long_buffer[47] = ’\0’;
long_buffer[48] = ’\0’;
long_buffer[49] = ’\0’;
bytes_written = fwrite(long_buffer, 1, 50,
image_file);
printf("\n wrote %d bytes", bytes_written);
printf("\n%s", long_buffer);
/***************************************
*
*
Now write the image data.
*
****************************************/
printf("\n length is %ld",
image_header->image_length);
printf("\n width is %ld",
image_header->image_width);
k = image_header->image_width;
if(image_header->bits_per_pixel == 4)
k = k/2;
image_buffer = (char *) malloc(k * sizeof(char ));
for(i=0; i<k; i++)
image_buffer[i] = 0x00;
for(i=0; i<image_header->image_length; i++){
bytes_written = fwrite(image_buffer, 1, k, image_file);
/***printf("\n wrote %d bytes", bytes_written);***/
}
fclose(image_file);
free(image_buffer);
Documents you may be interested
Documents you may be interested