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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:29:47+00:00 2026-06-11T10:29:47+00:00

I am trying to implement this code: package fortyonepost.com.iapa; import android.app.Activity; import android.graphics.Bitmap; import

  • 0

I am trying to implement this code:

package fortyonepost.com.iapa;  

import android.app.Activity;  
import android.graphics.Bitmap;  
import android.graphics.BitmapFactory;  
import android.os.Bundle;  
import android.util.Log;  

public class ImageAsPixelArray extends Activity  
{  
//a Bitmap that will act as a handle to the image  
private Bitmap bmp;  

//an integer array that will store ARGB pixel values  
private int[][] rgbValues;  

/** Called when the activity is first created. */  
@Override  
public void onCreate(Bundle savedInstanceState)  
{  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.main);  

    //load the image and use the bmp object to access it  
    bmp = BitmapFactory.decodeResource(getResources(), R.drawable.four_colors);  

    //define the array size  
    rgbValues = new int[bmp.getWidth()][bmp.getHeight()];  

    //Print in LogCat's console each of one the RGB and alpha values from the 4 corners of the image  
    //Top Left  
    Log.i("Pixel Value", "Top Left pixel: " + Integer.toHexString(bmp.getPixel(0, 0)));  
    //Top Right  
    Log.i("Pixel Value", "Top Right pixel: " + Integer.toHexString(bmp.getPixel(31, 0)));  
    //Bottom Left  
    Log.i("Pixel Value", "Bottom Left pixel: " + Integer.toHexString(bmp.getPixel(0, 31)));  
    //Bottom Right  
    Log.i("Pixel Value", "Bottom Right pixel: " + Integer.toHexString(bmp.getPixel(31, 31)));  

    //get the ARGB value from each pixel of the image and store it into the array  
    for(int i=0; i < bmp.getWidth(); i++)  
    {  
        for(int j=0; j < bmp.getHeight(); j++)  
        {  
            //This is a great opportunity to filter the ARGB values  
            rgbValues[i][j] = bmp.getPixel(i, j);  
        }  
    }  

    //Do something with the ARGB value array  
}  
}  

}

I can’t seem to figure out what this line of code does
bmp = BitmapFactory.decodeResource(getResources(), R.drawable.four_colors);
when i try to implement it, eclipse will say it can’t find what four_colors is, i’ve got no idea what it is and cant seem to figure it out.
Do you guys know what it is? and how should it be used?
thank 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-11T10:29:48+00:00Added an answer on June 11, 2026 at 10:29 am

    R is an automatically generated file that keeps track of the resources in your project. The drawable means the resource is of the type drawable, usually (but not always) meaning the resource is in one of your res/drawables-folders, e.g. res/drawables_xhdpi. Four_colors refers to the resource name, usually indicating the file you’re referring to is a file called ‘four_colors` (e.g. a PNG-file) in e.g. the res/drawables-xhdpi folder.

    So, the four_colors refers to the name of the (in this case) drawable your app trying to load.

    When Eclipse says it cannot find the resource, it means the resource is not included in the project where it should be included. E.g. you copied some code, but not the drawables that are referred to in the code.

    The line BitmapFactory.decodeResource(...) does exactly what it says; it decodes the encoded image into a bitmap, something Android can actually show. Usually when you use bitmaps it does this kind of decoding under the hood; here it’s done manually.

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

Sidebar

Related Questions

I have this code: package lijap.app.starcraft2counters; import java.io.File; import android.app.Activity; import android.os.Bundle; import android.os.Environment;
I am trying to implement this package http://code.google.com/p/python-progressbar/ when downloading a file like below:
I'm trying to implement this web api autocomplete in a standard mvc app. http://techbrij.com/987/jquery-ui-autocomplete-asp-net-web-api
I'm trying to create an android keyboard, this code works fine so far package
I am trying to implement this bit of code: func factorial(x int) (result int)
I'm trying to implement Orbit Slider in my homepage using this code: <script type=text/javascript
I'm trying to implement this accepted solution for displaying a custom error message: https://stackoverflow.com/a/5229581/141172
Using the latest Android Support Package v4 (December 2011), I'm trying to implement a
I'm trying to implement this algorithm description from a previous question I had here
I'm trying to implement this example http://jsfiddle.net/gzF6w/1/ (from another question here on stak) on

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.