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

  • Home
  • SEARCH
  • 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 7183177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:55:37+00:00 2026-05-28T17:55:37+00:00

In android, I’m trying to create a bitmap from a jpeg that I downloaded

  • 0

In android, I’m trying to create a bitmap from a jpeg that I downloaded and copied to a drawable folder under res.

attached is my code:

public void draw(Canvas g, Resources res, int x, int y, int w, int h) {
    Bitmap im = BitmapFactory.decodeResource(res, R.drawable.green_dragon);
    Bitmap im = BitmapFactory.decodeFile(R.drawable.green_dragon);
    g.drawBitmap(im, null, new Rect(x*w, y*h, (x*w)+w, (y*h)+h), new Paint());
}

Android does not recognize the R.drawable.green_dragon in either the decodeResource or decodeFile lines. I have also tried both refreshing and cleaning the application. Neither helped. When I looked up the image properties the type is File and the path is .jpg.

Thanks in advance for your assistance.

  • 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-28T17:55:38+00:00Added an answer on May 28, 2026 at 5:55 pm

    Only resources that are packaged with the application can be referenced using the R object.

    Anything you download must either be saved to a database or a file. I’m assuming you’ve already downloaded and saved the file. At which point you either need the a String that has the Path of the jpg or a FileDescriptor for the jpg.

    Once you have either you can load the bitmap using:

    Bitmap bmp = BitmapFactory.decodeFile( PathToFileString ); 
    

    or

    Bitmap bmp = BitmapFactory.decodeFileDescriptor( fileDescriptorObject );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Android Asus tablet is acessing images from android mdpi drawable and also lgoptimusp509 is
Android comes with lots of system resources ( android.R ) that can be used
Can Android OS that is installed on actual devices be emulated in VMWare or
Android - What is the maximum file size that setMaxFileSize can be set to
Android got XML layout design with a tool that allow you to drop and
Android google maps sdk approximate zoom level to discrete values. I mean that i
Android's AlarmManager Javadoc states When an alarm goes off, the Intent that had been
(Android 3.0+) How would I create a Spinner for use as an Action Item
Android 2.1 - Eclipse What steps will reproduce the problem? 1. Create new Texture(managed)
On Android devices, does anyone has checked that if a user clicks on a

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.