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 901027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:29:30+00:00 2026-05-15T15:29:30+00:00

I am attempting to create a mosaic of images in Java. I calculate the

  • 0

I am attempting to create a mosaic of images in Java. I calculate the size of the new image I’m creating, and then for each subimage that will be part of the mosaic, I do a paint call.

In pseudocode:

create buffered image big enough to hold entire mosaic
create Graphics2D context from that image

for each buffered subimage that will be a part of the mosaic
   draw the subimage on the graphics context of big bufferedimage
   g2.drawImage(myImage, x,y,width,height,null,null)

Is there a better way to do this? I’d hope there’s some sort of direct copying operation available, since I don’t want to transform or scale the subimages into the bigger image. Something akin to an arraycopy of the rasters of each subimage. I notice there’s a setData method that takes in a Raster object, but the method notes that the Raster has to be in same coordinate space.

Any thoughts? This is a bit of a bottleneck in my program and I’d like it to be as fast as possible.

EDIT:
It turns out I was wrong (as is often the case when assumptions are made without hard data) about where the bottleneck was. I had a bug where multiple 3MB pictures were being read over and over again rather than using the scaled down versions of the images cached in memory. My running time went from 50 minutes to 15 seconds when I made the fix.

  • 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-05-15T15:29:31+00:00Added an answer on May 15, 2026 at 3:29 pm

    Typically the drawImage() call will directly map on a hardware accelarated blit operation. Depending on the driver/graphics card and JVM you are using, also scaling should be hardware accelerated. However if you can avoid scaling you should of course.

    If the sub-images do fit in the larger image you should be able to avoid scaling by choosing your width and height such that they are the same as that of the subimage, of course in this case you are better of using g.drawImage(Image img, int x, int y, ImageObserver observer).

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

Sidebar

Related Questions

So I am attempting to create a search field that will filter contacts on
I'm attempting to create thumbnails out of some images, each of which isn't necessarily
I am attempting to create an inbound Mule endpoint that will receive Syslog messages
I am attempting to create a Scala method that will take one parent group
I'm attempting to create a Windows application that will allow the controls on earbuds/headphones
I'm attempting to create a very large image in Java like so: BufferedImage bi
I'm attempting to create an xquery expression that will return selected nodes but will
I am attempting to create a manual build in Jenkins that will build a
Im attempting to create a new operator :? on lists, which operates the same
I am attempting to create a report, utilizing a matrix, that only displays columns

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.