Reading ITERATES.TGA using Java
Hi All, I'm writing a Java program where I want to read in the ITERATES.TGA file produced by Fractint (using truecolor=yes). I am successfully able to read in the TGA header and get the image dimensions and maxiter information; here's my code for that: // read in header info dis.skip(12); b1 = dis.readUnsignedByte(); b2 = dis.readUnsignedByte(); xdots = b1 + (b2 << 8); b1 = dis.readUnsignedByte(); b2 = dis.readUnsignedByte(); ydots = b1 + (b2 << 8); System.out.println("xdots: " + xdots+ "; ydots: "+ydots); dis.skip(2); b1 = dis.readUnsignedByte(); b2 = dis.readUnsignedByte(); b3 = dis.readUnsignedByte(); b4 = dis.readUnsignedByte(); maxiter = b1 + (b2 << 8) + (b3 << 16) + (b4 << 24); System.out.println("maxiter: " + maxiter); However, the trouble occurs when I try to read in the iteration values -- I think I've determined that there are three bytes per iteration value, but for the life of me I can't figure out how to shift/add the bytes to produce the iteration values I expect to see (1, 2, 3, etc.). Here's the closest I think I may have come to the correct code: b1 = dis.readUnsignedByte(); b2 = dis.readUnsignedByte(); b3 = dis.readUnsignedByte(); System.out.println("b1-3 : "+b1+" "+b2+" "+b3); long iteration; iteration = b1 + (b2 <<8) + (b3 << 16); Looping through the entire file, all I ever get back is: b1-3 : 200 153 51 iter : 3381704 It doesn't matter where I am in the TGA file; the values returned never seem to change! Is it possible that my code is working, and the TGA produced by Fractint is simply "flat"? Unfortunately, I don't know of another way to check to see if the TGA actually contains iteration values or not. Any suggestions would be most welcome! Background: I'm writing a program that will read in the ITERATES.TGA file and write out an ASCII GRID file that can then be imported into Esri's ArcGIS (www.esri.com). My eventual goal is to be able to use ArcGIS' spatial analysis tools to analyze some characteristics of the Mandelbrot set. Thanks in advance for any thoughts or helpful responses! Cheers, Jason P.s. Tim, if you're reading this, yes, you helped me back in 1998 with a similar question when I was writing "Deeper" in C++. :-) -- Cheers from Mr. Tumnus! "Here... take my handkerchief." Hoofing it bare-chested since 1974.
Jason Hine wrote: <snip>
Background: I'm writing a program that will read in the ITERATES.TGA file and write out an ASCII GRID file that can then be imported into Esri's ArcGIS (www.esri.com). My eventual goal is to be able to use ArcGIS' spatial analysis tools to analyze some characteristics of the Mandelbrot set. <snip>
In producing the .tga file with Fractint, have you used the other relevant parameter?
From fractint.doc (from Fractint 20.04, patch11), page 133: (...) TRUECOLOR=yes You can save either the default color scheme or the iteration escape value to a file called FRACTxxx.TGA. This will allow experimentation with truecolor algorithms. A C language source file that reads the file when iterates are used, is provided. Someday we'll have REAL truecolor support ...
TRUEMODE=def|iter Determines whether the FRACTxxx.TGA file produced when TRUECOLOR=yes contains the iteration value or the default coloring scheme. (...) It's also possible (part of) this feature got broken along the way and no-one noticed until now. Regards, Gerald
Jason,
I'm writing a Java program where I want to read in the ITERATES.TGA file produced by Fractint (using truecolor=yes).
However, the trouble occurs when I try to read in the iteration values -- I think I've determined that there are three bytes per iteration value, but for the life of me I can't figure out how to shift/add the bytes to produce the iteration values I expect to see (1, 2, 3, etc.). Here's the closest I think I may have come to the correct code:
b1 = dis.readUnsignedByte(); b2 = dis.readUnsignedByte(); b3 = dis.readUnsignedByte(); System.out.println("b1-3 : "+b1+" "+b2+" "+b3); long iteration; iteration = b1 + (b2 <<8) + (b3 << 16);
Looping through the entire file, all I ever get back is: b1-3 : 200 153 51 iter : 3381704
This should work. What value are you using for maxiter? Which version of Fractint are you using. If you are seeing an iterates.tga file, you need to use a newer version of Fractint. The developer's version (20.4 patch 11) works as I expect with truecolor=y and truemode=iter, and generates fractxxx.tga files. Using a TGA file viewer shows a mostly black image with a trace of blue around the lake (which is blue) with the default settings. I have a vague recollection that this feature was broken at one time, but I don't recall when it got fixed or what the problem was. Jonathan
participants (3)
-
Gerald K. Dobiasovsky -
Jason Hine -
Jonathan Osuch