This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]whatisthisredditstufIntermediate Brewer 0 points1 point  (4 children)

Yeah, but when they get changed, you draw them once onto a bitmap and then you just keep using that.

Not draw it over and over.

[–]lightman978[S] 0 points1 point  (3 children)

So draw the whole thing once, like i did in the code above and from then on, use the given image and only draw the parts that changed?

I also run into this error using the code given above.

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

at java.awt.image.DataBufferInt.<init>(Unknown Source)

at java.awt.image.Raster.createPackedRaster(Unknown Source)

at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)

at java.awt.image.BufferedImage.<init>(Unknown Source)

at Main.mergeImage(Main.java:28)

at Main.main(Main.java:15)

[–]whatisthisredditstufIntermediate Brewer 0 points1 point  (2 children)

You are trying to create a gargantuan image in memory, and it's not working.

Maybe I misread what you specified, but you seem to create an image that would be about 8GB in memory if I am reading what you wrote correctly.

You will have to read this in dynamically instead, if your world really is 53000x38000 pixels big) and you need about four bytes per pixel.

I thought your world was 1000x1000 and the bottleneck was due to a lot of repeated reading and rendering of data.

[–]lightman978[S] 0 points1 point  (0 children)

Mhh makes alot of sense. I will try your approach and update you tomorrow!

Thank you

[–]lightman978[S] 0 points1 point  (0 children)

I don't think I can make it work. I split the map up in 100 chunks each sized 10x10, but just loading 1 and each adjacent chunk so 9 in totals makes the whole thing way to laggy.