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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:48:44+00:00 2026-05-15T14:48:44+00:00

Here’s a snip that successfully reads off, to Eclipse LogCat, the height and width

  • 0

Here’s a snip that successfully reads off, to Eclipse LogCat, the height and width of the .PNG on the SD card:

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

//...

        Bitmap bmp = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath() + "/sample.png"); 
        int width = bmp.getWidth(); 
        int height = bmp.getHeight();
        int[] pix = new int[width * height]; 
        bmp.getPixels(pix, 0, width, 0, 0, width, height); 

        int R, G, B; 

        for (int y = 0; y < height; y++){
            for (int x = 0; x < width; x++) 
            {               
                int index = y * width + x;

                R = (pix[index] >> 16) & 0xff;     //bitwise shifting
                G = (pix[index] >> 8) & 0xff;
                B = pix[index] & 0xff;

    // [This is where I'd put it.  But I can't get a red line off the editor when I do anything.]  
            }
        }

        Log.v(TAG, width + "  " + height); 

My problem: I can’t for the life of me use Log.v() to report the value of R or G or B. Everything I’m doing draws a red line under v or something when I try. I’ve tried toString() and everything. Help please. 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-15T14:48:44+00:00Added an answer on May 15, 2026 at 2:48 pm

    You’d have to log within the loop in order to log each pixel. Was that where you were trying to log it?

    If you were trying to log it at the same place as the height and width, which pixel’s value were you expecting to log? What if the image was empty? If this is what you were trying to do, the error would be due to the use of uninitialized variables… but that error just leads to a deeper question of exactly what you’re trying to do.

    EDIT: Okay, so it turns out it was slightly different – this is a good example of why it’s important to give the code which is failing as well as the code which isn’t, and say what the error message is.

    So you were trying to call a method with this signature:

    void v(String, String)
    

    But you were trying to call it like this:

    Log.v(TAG, R);
    

    which is trying to pass an int as a String. You need to convert the int value to a string. IMO, the best way to do this is with String.valueOf:

    Log.v(TAG, String.valueOf(R));
    

    Having said that, if you do any string concatentation, the compiler will add the conversion for you. So you could do either of these:

    Log.v(TAG, R + " " + G + " " + B);
    Log.v(TAG, "Red: " + R);
    

    As a side note, I would strongly suggest that if this is giving you a hard time, it would be worth reading a good introductory Java book – one which doesn’t focus on Android – and try writing small Java console apps for a while. It’s hard enough learning how to develop on a new client platform to start with, without trying to learn a language at the same time. By putting in a bit more time on the language up-front, you’re likely to save effort in the long run.

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

Sidebar

Related Questions

Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here is my work environment: Eclipse Juno as IDE with maven2 plugin on it
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here's my Manifest: <?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.mappp.mobile android:versionCode=1 android:versionName=1.0 > <supports-screens android:largeScreens=true
Here is the problem that I am trying to solve. I have two folders
Here's a query that works fine: SELECT rowid as msg_rowid, a, b, c FROM
Here is my code (Say we have a single button on the page that
Here's the flow that I am trying to achieve: 1) User uploads an audio
Here is another spoj problem that asks how to find the number of distinct
Here's a basic regex technique that I've never managed to remember. Let's say I'm

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.