小编Dyl*_*gan的帖子

Android- 将 ARGB_8888 位图转换为 3BYTE_BGR

我通过这样做得到我的 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 ) 上的位置。
任何帮助表示赞赏!

java android bytebuffer image bitmap

4
推荐指数
1
解决办法
4313
查看次数

AlertDialog上的android-setAdapter无法正常工作

我正在弹出框中列出用户的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)

java android handler listadapter android-alertdialog

1
推荐指数
1
解决办法
1504
查看次数