At 5:54 PM -0300 1/25/03, Ricardo Montiel wrote:
Hi,

I need to convert lots of diagrams as the enclosed file to ASCII characters.
<snip>

This is the way I'd do it. Maybe it's not the best way, but it should work.
1) Loop over each location of your image starting at the upper-right
2) If the current section is uncolored, do a flood-fill with a new color
3) write out the ascii number of the color at the current location to an array.

You said that your files might come in different file formats. You're right that sticking with one is a good idea. You can use something like GraphicConverter to put them all into the same format. (Or you could write a Perl script to do it too).

You asked about MacPerl, so we're assuming you're not doing this under OS X. That might eliminate some things like ImageMagick or GD for file manipulation. However, unless you're also looking to do complicated image transforms, QuickDraw from the Macintosh Toolbox is adequate for your needs. You can use routines in the Toolbox to read in PICTS and perform flood-fills, and find out the value of the current pixel and etc.

MacPerl comes with an interface to the Toolbox. The Toolbox routines themselves are documented by Apple in the developer section of www.apple.com.

There are also some example scripts posted on the MacPerl website that use QuickDraw under MacPerl.

-Jeff Lowrey

Reply via email to