Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:52:48+00:00 2026-06-14T20:52:48+00:00

I am creating a cricle gradient using RadialGradientPaint, putting that on a BufferedImage and

  • 0

I am creating a cricle gradient using RadialGradientPaint, putting that on a BufferedImage and rendering the Image on top of my 2d game screen, creating a nice light-in-the-dark effect. I would, however, like to create more light sources, but creating and rendering a new BufferedImage for each light doesn’t do the job (usually just the last light is seen, everything else is black). Is it possible to bake a few RadialGradientPaints into one BufferedImage or achieve the multiple lights effect in some other way?

Attached you can find the image of how one light looks like. It is a black BufferedImage with a RadialGradientPaint applied rendered on top of the screen. I would like to add more of these somehow.

Single light

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:52:50+00:00Added an answer on June 14, 2026 at 8:52 pm

    Solution to this problem is using this (as pointed in the comment by @JanDvorak : Merging two images

    The exact code I use is this:

    public static BufferedImage mergeImages2(BufferedImage base, Collection<Light> images) {
        BufferedImage output = new BufferedImage(base.getWidth(), base.getHeight(), BufferedImage.TYPE_INT_ARGB);
    
        Graphics2D g = output.createGraphics();
        g.drawImage(base, 0, 0, null);
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN, 1.0f));
        for (Light l : images) {
            g.drawImage(l.LIGHT_IMAGE, l.x, l.y, null);
            l.LIGHT_IMAGE.flush();
        }
        g.dispose();
        output.flush();
        return output;
    }
    

    NOTE: This solves the problem but produces memory leaks, which I have described hoping for some help here: BufferedImage.createGraphics() memory leak

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a simple RPG game, first time using XNA. Trying to get my character
I am creating an app where there will be ~10 circles on screen, that
When creating circles using D3, is it possible to create a group such that
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
I creating a web application using JSF,Hibernate,Spring. I have added a filter for checking
I am creating a Circle using the google.maps.Circle() method. This all works fine and
I am creating these icons as an image wrapped with a CSS circle behind
I'm creating graphs using JFreeChart: The problem should be fairly clear. My circles which
I'm creating a simple drag and drop game with jquery's draggable plugin. There are
I'm creating a spotlight that moves over content in my app, like so: In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.