Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Add padding to large images  RSS feed

 
will phillips
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a little program that slices up an image and part of the process requires varying amounts of padding be added around the image to ensure the tiles are the correct size and to ensure they line up with other images; the method I am currently using, as seen below, works to get the proper padding around the image. My concern with this method is memory usage on larger images, specifically PNG that are 20MB to 30MB in size with dimensions ranging from 10000px by 5000px to 15000px by 8000px. Testing on the smaller of the images results in memory usage of around 350MB just from loading and blossoms to just under 800MB when the padding is added. I'm looking for a way to add padding to an image without the need to duplicate the entire thing in memory, I would appreciate any suggestions.




Couple things of note:
-I don't display this image at any point
-I won't ever save a modified version of the original image, just a bunch of tiles.
-I did look at editing the underlying data-structure, but between there being substantially more items in that data structure then pixels in the image and it being a byte[] instead of the int[] people said it should be, I was a little bit lost there.
-I assumed this to be the correct forum for this since I am using AWT components.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!