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.