in article p05200f01ba59ab45da01@[192.168.136.25], Jeff Lowrey at [EMAIL PROTECTED] wrote on 26/01/2003 12:27:
> 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. Probably is a proof of my ignorance in these questions (haven't had the need to read and parse a binary file before), but I'm puzzled with the suggested approach - Why is the need to fill background pixels with different colors instead of reading their actual value? I just can't see the need of doing so. At first sight, I would prefer a direct approach. As I said, probably it is just me. > 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. Yes, I thought on GC. Besides I believe that there are some freeware utilities that may help as well, which can process folders plenty of files. > (Or you could write a Perl script to do it too). Not by now, as there other ways to make file format conversions (GC, etc). > You asked about MacPerl, so we're assuming you're not doing this > under OS X. Yes, your assumption is correct and the reason why I mentioned MacPerl (get non ported modules out of question) - This Mac it's an old PPC 8500/120 under Mac OS 8.6. If needed, it can boot under Mac OS 9.1, but no way under Mac 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. A code example of how to read the value of a pixel would be great - basically is what I don't know how to code. > 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 Thank you, I will take a look at those scripts and see what I find out. Ciao, Ricardo