View previous topic :: View next topic |
Author |
Message |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Thu Jun 30, 2011 10:13 am Post subject: BRAIN FART :D |
|
|
I found a new way to handle making the fractal string in FractalGen. Fractals that once took up to a minute to process (9th orders and up mostly) can now be done in about 5 seconds  |
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Jun 30, 2011 10:25 am Post subject: |
|
|
bet i can get it down to less than 1 second |
|
Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Thu Jun 30, 2011 11:21 am Post subject: |
|
|
Slugsnack wrote: | bet i can get it down to less than 1 second |
Pretty sure you could, But I'm not that much of a tinkerer. I used to have it iterate through the atom string and construct the next order string as it iterates. So character by character. Now it does them all at once, replacing all the Fs with it's string, Xs with it's string etc.
I'm also doing the drawing to a buffered image, then loading the buffered image into the panel so it isn't redrawing the entire fractal while you scroll. I believe that was something you had suggested I do right?
The only problem now is that I get out of memory errors when trying to create large pictures. The max I can get is around 4609X4609. Which is the normal size of the 8th order attached, although I'm sure the forum will resize it. |
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Jun 30, 2011 11:53 am Post subject: |
|
|
if you want to avoid the memory issues don't put the whole bufferedimage onto the screen. only show the part which is currently on there. cache the surroundings in memory then store the rest on disk or something. so you have a virtual image instead. i don't know if there's already an existing library to do this. probably there is |
|
Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Thu Jun 30, 2011 11:57 am Post subject: |
|
|
Slugsnack wrote: | if you want to avoid the memory issues don't put the whole bufferedimage onto the screen. only show the part which is currently on there. cache the surroundings in memory then store the rest on disk or something. so you have a virtual image instead. i don't know if there's already an existing library to do this. probably there is |
The error isn't from displaying the bufferdimage, it's whenever I create it. See after I create the fractal instruction string, I iterate through it to create bounds so the entire fractal is visible. Then I create a bufferedimage with those bounds before drawing the fractal to it. It's whenever I create it:
Code: | image = new BufferedImage((int) refX2 + 1, (int) refY2 + 1, BufferedImage.TYPE_INT_ARGB); |
That's when the error occurs. |
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Jun 30, 2011 12:01 pm Post subject: |
|
|
yes but if you store the image on disk, you can just read a certain portion of it out and display that as a bufferedimage each time. also you'd need to store it as you go along when creating |
|
Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Thu Jun 30, 2011 12:07 pm Post subject: |
|
|
Slugsnack wrote: | yes but if you store the image on disk, you can just read a certain portion of it out and display that as a bufferedimage each time. also you'd need to store it as you go along when creating |
I see what you're saying now. I thought you meant just store the whole image to disk, not store it as I create it, presumably deleting the portion I don't need of the buffer.
I have a question though. I don't think it is entirely the image causing this problem, as the saved image(which uses the same buffer) is only 200 sumthing kilobytes. Do you think it could be the fractal string? It's a single string containing millions of characters.
EDIT: Just answered my own question. Millions of characters equals megabytes of memory. It's the string that I need to save to disk and parse is little bits, not the image.
Last edited by Evil_Intentions on Thu Jun 30, 2011 12:12 pm; edited 1 time in total |
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Jun 30, 2011 12:11 pm Post subject: |
|
|
millions should be okay to be honest. you can test it out for yourself though. just comment out the code doing the image generation and see if it still throws the exception |
|
Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Thu Jun 30, 2011 12:16 pm Post subject: |
|
|
Slugsnack wrote: | millions should be okay to be honest. you can test it out for yourself though. just comment out the code doing the image generation and see if it still throws the exception |
Read the edit above. I am correct that 1 character is 8 bits or 1 byte right?
I just tried commenting out the drawing portion. I still got errors, although I had to use a higher order to get them. Mostly because I think it was the little extra memory the image used up that was enough to cause the error. |
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
|
Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Thu Jun 30, 2011 12:27 pm Post subject: |
|
|
Ah. So I need to stream the instructions into a file while creating them, and stream them out as I'm drawing.
Will work on that later, but for now, Katamari :3
Thanks slugsnack. |
|
Back to top |
|
 |
|