我通过这样做得到我的 ARGB_8888 位图的像素数据:
public void getImagePixels(byte[] pixels, Bitmap image) {
// calculate how many bytes our image consists of
int bytes = image.getByteCount();
ByteBuffer buffer = ByteBuffer.allocate(bytes); // Create a new buffer
image.copyPixelsToBuffer(buffer); // Move the byte data to the buffer
pixels = buffer.array(); // Get the underlying array containing the data.
}
Run Code Online (Sandbox Code Playgroud)
但是,我想将每个像素存储在四个字节 (ARGB) 上的数据转换为每个像素存储在 3 个字节 ( BGR ) 上的位置。
任何帮助表示赞赏!
我正在弹出框中列出用户的tumblr博客.所有这些都发生在Handler中.这是代码:
private class PicHandler extends Handler{
Context c;
String name;
JumblrClient client;
public PicHandler(Context context, String n, JumblrClient cl){
c=context;
name = n;
client = cl;
}
public void handleMessage(Message msg)
{
final String[] cs = preferences.getString("allBlogs", "").split(",");
for (String s : cs){
Log.d("DrawLog", s); //logs the blogs correctly
}
ListAdapter adapter = new ArrayAdapter<String>(
getApplicationContext(), android.R.layout.simple_selectable_list_item, cs);
Log.d("DrawLog", (String) adapter.getItem(0)); //logs the first blog correctlys
new AlertDialog.Builder(c)
.setTitle("Choose blog")
.setMessage("Choose the blog to publish the .gif")
.setAdapter(adapter, new DialogInterface.OnClickListener() …Run Code Online (Sandbox Code Playgroud)