Sign in to follow this  

Blend pixel data without leaking memory

Recommended Posts

Is there a way to blend pixels directly to Raster in a BufferedImage with custom blending using own pixel loops instead of cloning the source pixels with getDataElements? I tried inheriting from Composite and CompositeContext but the permanent memory leak causes crashes when the memory runs out. I need custom blending for light effects so AlphaComposite is not enough for my project. In the worst case, I just make my own image type using arrays as I usually do in C.

Share this post


Link to post
Share on other sites
It seems like Java is leaking because it creates an intermediate image for interpolation so when I first draw to an image that I recycle myself using AlphaComposite.Src and drawRenderedImage, I can then use my custom composite in a 1:1 scale ratio without leaking memory. The wasted time is acceptable because the operation is only performed when the level is loaded.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this