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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:05:05+00:00 2026-06-02T05:05:05+00:00

i wanna read an image from my computer and store it in my c++

  • 0

i wanna read an image from my computer and store it in my c++ program. i have some experience in java image processing but totally no idea how to do it in c++. i wanna achieve what the java code below does in c++:

BufferedImage sourceImage = null;

 try {
        // The ClassLoader.getResource() ensures we get the sprite

        // from the appropriate place, this helps with deploying the game

        // with things like webstart. You could equally do a file look

        // up here.

        URL url = this.getClass().getClassLoader().getResource(ref);

        if (url == null) {
            fail("Can't find ref: "+ref);
        }

        // use ImageIO to read the image in

        sourceImage = ImageIO.read(url);
    } catch (IOException e) {
        fail("Failed to load: "+ref);
    }

    // create an accelerated image of the right size to store our sprite in

    GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    Image image = gc.createCompatibleImage(sourceImage.getWidth(),sourceImage.getHeight(),Transparency.BITMASK);

    // draw our source image into the accelerated image

    image.getGraphics().drawImage(sourceImage,0,0,null);

    // create a sprite, add it the cache then return it

    Sprite sprite = new Sprite(image);
    sprites.put(ref,sprite);

    return sprite;

Anyone can give me a hint? Thanks in advance!

  • 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-02T05:05:08+00:00Added an answer on June 2, 2026 at 5:05 am

    You can use the OpenCV library if you want to work with your image as matrix.
    This library provides a simple interface of image loading and storing, but it’s main application is image processing and computer vision. So it can be an “artillery against a bird”.

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

Sidebar

Related Questions

i wanna read an image (TIF image) from FTP Server and then view it
i wanna read all the lines from a text so am doing this int
I read how to do it with a service, but i wanna know if
i wanna read file in an other activity but i made it in another
I wanna read text between <p></p> tags which comes from database field. I think
Okay, I am using (PHP) file_get_contents to read some websites, these sites have only
I just wanna display the contents of files from sdcard on emulator (as image
I have a file and I don't wanna take a copy from this file.
I have read a few posts about what I need but I can't manage
I'm using a background thread to read from a Sqlite database some GPS data...and

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.