text digitization

J

jimgardener

i am trying to digitize a text file into tiff image.the algorithm is
as follows,
There is a 8x16, 256 character font table with 16 columns and 256
rows .each row of table represents a character(like 0...32,A,a etc)
and each column represents a row of font (font is of height
16).elements of the table are like 0x00,0x7e,0x81,0xff etc.Finding the
dot pattern for any character is done by using the value of a
character as one index into the font array, with the font row being
the other index.
i want to get a line of text from the file and using a for loop of 16
times (fontheight is 16) each character is examined and values are
taken from the font table
if textline is a line of text (probably obtained by readLine() of
BufferedReader)
int imageoffset=0;
for (int row=0 ; row<FONTHEIGHT ; row++){

for(int i=0;i<lengthof_textline;i++){
if(textline>SPACE){
bitimage[imageoffset++]=fonts[textline][row] ;
}
}
bit_image[imageoffset++]=EOLFLAG ;

}


here some constants are used to denote EOLFLAG ,SPACE etc
EOLFLAG =0x01 (hoping it will not occur for any in font data)
SPACE =0x20

the idea is to build bit_image with these hexadecimal values and
finally use this array to write an image(Tiff).There are some points
i would like to know
1.should i use a char array to represent bit_image? i believe that the
font table's array should be char[16][256] .
2.if bit_image is a char array filled with these font codes,can any
api translate it to a tiff image?I couldn't work out how to do this
using JAI.if anyone can ,pls help
jim
 
J

jimgardener

own font data and maps that into an explicit two-dimensional array based
on the text input?

yes, i need to use a given font data array .
in c ,this could be done using char data type for each value like
0x81,0xff...i was not sure how to proceed in java.i guess i will have
to use char and not byte because byte b=0x81 will cause type
mismatch..
if i build a array of chars containing these font values ,then i need
a way to use that as image data of tiff..this is something i (with my
limited exp)couldn't find in JAI..
 
N

Neil Coffey

jimgardener said:
i am trying to digitize a text file into tiff image.the algorithm is
as follows,
There is a 8x16, 256 character font table with 16 columns and 256
rows .each row of table represents a character(like 0...32,A,a etc)
and each column represents a row of font (font is of height
16).elements of the table are like 0x00,0x7e,0x81,0xff etc.Finding the
dot pattern for any character is done by using the value of a
character as one index into the font array, with the font row being
the other index.

It sounds to me like you're trying to program Java like you'd
program a ZX Spectrum. The great thing about modern programming
languages is that they provide libraries for things like image
manipulation without you having to poke about with raw bytes and
ints...

Why not:
- for each character in the font table, create a BufferedImage for
that character, reading from the table and calling setRGB() to
set each pixel of the character as appropriate
- create a BufferedImage to hold your final image, then for each
character you need to place on it, call drawImage(), with one
of the font
2.if bit_image is a char array filled with these font codes,can any
api translate it to a tiff image?I couldn't work out how to do this
using JAI.if anyone can ,pls help

Yes, JAI allows you to save an image as a TIFF file. But you go from
an image object, not from a raw primitive array.

Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top