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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:11:09+00:00 2026-05-20T00:11:09+00:00

In my project users uploads picture. Some times it is smaller than expected. I’d

  • 0

In my project users uploads picture. Some times it is smaller than expected.

I’d like to create a default size white(empty) image and place users image(small) at the center
of the white image. In other words, i want to cover all sides of a small image with white pixels.

How can i do it with java?

I am not good in java image processing.
But i use BuferedImage to expand uploaded image.

BufferedImage newImage = new BufferedImage(50, 50,  BufferedImage.TYPE_INT_RGB);
newImage.getGraphics().drawImage(srcImage, 0, 0, srcImage.getWidth(), srcImage.getHeight(), null);

The above code, fills black color if the source image width and height is less than 50.
The source image is rendered from left top and remaining area is filled by black.

Is it possible to move the source image to center and fill the remaining pixels with white color.

Any suggestions will be appreciative.

Thanks

  • 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-20T00:11:10+00:00Added an answer on May 20, 2026 at 12:11 am

    Did you try
    newImage.getGraphics().translate((25-srcImage.getWidth()/2), (25-srcImage.getHeight()/2)); ?

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

Sidebar

Related Questions

In a project I'm starting I would like to give privileges to users based
I'm working on a project that currently has zero users but we would like
I am working currently on a web project where users can create image galleries
Hello internet techno-persons, I am writing a project for users to create documents from
I am currently working on a project where users need to be able to
Possible Duplicate: VS2008 Setup Project: Shared (By All Users) Application Data Files? Please can
A project I'm working on supposed to authenticate users agains AD. I've never worked
The project I´m working on needs to auth its users against AD, and as
I've got a number of non-technical users that all share a set of project
I'm running an open source project and every now and then Chinese users report

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.