代码之家  ›  专栏  ›  技术社区  ›  toto_tata

Java:位图时出现问题。setPixel()替换为位图。设置像素()

  •  0
  • toto_tata  · 技术社区  · 4 年前

    我有以下代码:

     Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_4444); 
    
        for (int y = 0; y < HEIGHT; y++) {
            for (int x = 0; x < WIDTH; x++) {
                int index = y * WIDTH + x;
                bitmap.setPixel(x, y, Color.argb(255, 0, mask[index],0)); // mask is an array of int between 0 and 255 
            }
        }
    

    它工作正常:我得到我的位图,但。。。这段代码非常慢。

    我试着用以下内容取代它:

     Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_4444);
    bitmap.setPixels(mask, 0, WIDTH, 0, 0, WIDTH, HEIGHT);
    

    但这是行不通的。我得到一张黑色的照片。

    有人能帮忙吗?

    谢谢

    0 回复  |  直到 4 年前