这里有一个剪断,成功地读完,到Eclipse的logcat,高度和.PNG的宽度在SD卡上:我不能LogCat这个值。为什么?
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);
我的问题:我不能为我的生活使用Log.v ()来报告R或G或B的值。当我尝试时,我正在做的所有事情都会在v
之下绘制一条红线。我试过toString()和一切。请帮助。谢谢。
我已经添加了我将Log.v放在哪里,如果它工作。这里的问题是:我在那里做的任何事情都无法让R或G或B在Eclipse编辑器中使用语句中的某些内容而没有使用红线。我不知道该写什么。试试这个,如果你可以在添加了snip的HelloAndroid上(以及可执行的导入),因为我无法获得一个语句来报告TGB值。感谢您的帮助。 – user225626 2010-06-30 06:30:19
@ user225626:在那里应该没问题。请显示您尝试使用的确切行*和* Eclipse向您显示的错误消息。 – 2010-06-30 06:35:40
'RGB',而不是'TGB'。现在这里的评论编辑正在按照我的方式。 (几分钟后不允许我编辑) – user225626 2010-06-30 06:37:26