[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ASCII art / FIGlet



Idea:

To get the best ASCII representation of a Hires graphic, you would need
to
"OCR" the HIRES screen, and pick an ASCII character whose bit map most
closely matches the area on HGR screen.

I don't remember the resolution of the TEXT screen bitmaps.  You would
have
to take into account the fact that there is ?1? pixel between each text
character.

Also would need a bitmap of the entire ASCII text character set.  This
is stored
in ROM and I don't think it is accessible to the programmer.   I have
the bitmaps
on a disk at home.

if  a text character is X pixels wide and Y pixels high:
X = text character width
Y = Text character height

for X1 = 0 to 279 step X    :rem these cycle through the entire HGR
screen
  for y1 = 0 to 191 step Y :rem might have to be +1 to take into
consideration 1 pixel
                                            between each text character
on text screen


    REM:  cycle through X wide by Y tall pixels and store them in
BYTE(vert)

    vert=0: rem counter for BYTES pulled from screen
    for y2 = y1 to y1+y
       bitvalue=1

            for x2 = x1 to x1+x
                 if scrn(x2,y2) = 1 then bytevalue=bytevalue+bitvalue
                 bitvalue=bitvalue*2
            next x2

    byte(vert)=bytevalue
    vert=vert+1
    next Y2

now we'have a bitmap of X wide Y tall area of screen.

need to compare it to the bitmaps of all ASCII characters
and figure out which one has the closest match.

    FOR I = 0 to (number of ascii bitmaps in table)

    for y3= 0 to y    REM height of ascii characters
         for x3= 0 to x
           if bitmap(x,y) = byte (x,y) then similarity = similarity +1
           if bitmap(x,y) <> byte (x,y) then similarity = similarity -1
         next x3
    next y3

    similarity(i)=similarity
    next i

Now find which has the highest similarity:

    best match = 0
    for i=0 to (number of characters in bitmap table)
      if similarity(i) > best match then bestmatch = similarity(i):
bestmatchNumber=i
    next i

<<store to text screen>>

next x1  :rem go get next bitmap from HGR screen
next y1



it should spit out bestmatchNumber which would be the number of the
ascii
character in the bitmap table which most closely matches the screen
pixels.

SCRN function is on my website http://rich12345.tripod.com   from the
robot
arm projects book by Blakenship.

Rich