Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 位图设置像素/像素无效 TextView-loadingText=(TextView)findViewById(R.id.loadingText); loadingText.setTextSize(36); 加载text.setText(“变形…”); 位图leftbm=((BitmapDrawable)leftImage.getDrawable()).getBitmap(); 位图rightbm=((BitmapDrawable)rightImage.getDrawable()).getBitmap(); 位图newbm=leftbm.copy(Bitmap.Config.ALPHA_8,true); int[]像素=新int[newbm.getHeight()*newbm.getWidth()]; getPixels(像素,0,newbm.getWidth(),0,0,newbm.getWidth(),newbm.getHeight()); 如果(!newbm.isMutable()){ Log.d(“可变检查”,“”+newbm.isMutable()); 返回; } 对于(int i=0;i_Java_Android - Fatal编程技术网

Java 位图设置像素/像素无效 TextView-loadingText=(TextView)findViewById(R.id.loadingText); loadingText.setTextSize(36); 加载text.setText(“变形…”); 位图leftbm=((BitmapDrawable)leftImage.getDrawable()).getBitmap(); 位图rightbm=((BitmapDrawable)rightImage.getDrawable()).getBitmap(); 位图newbm=leftbm.copy(Bitmap.Config.ALPHA_8,true); int[]像素=新int[newbm.getHeight()*newbm.getWidth()]; getPixels(像素,0,newbm.getWidth(),0,0,newbm.getWidth(),newbm.getHeight()); 如果(!newbm.isMutable()){ Log.d(“可变检查”,“”+newbm.isMutable()); 返回; } 对于(int i=0;i

Java 位图设置像素/像素无效 TextView-loadingText=(TextView)findViewById(R.id.loadingText); loadingText.setTextSize(36); 加载text.setText(“变形…”); 位图leftbm=((BitmapDrawable)leftImage.getDrawable()).getBitmap(); 位图rightbm=((BitmapDrawable)rightImage.getDrawable()).getBitmap(); 位图newbm=leftbm.copy(Bitmap.Config.ALPHA_8,true); int[]像素=新int[newbm.getHeight()*newbm.getWidth()]; getPixels(像素,0,newbm.getWidth(),0,0,newbm.getWidth(),newbm.getHeight()); 如果(!newbm.isMutable()){ Log.d(“可变检查”,“”+newbm.isMutable()); 返回; } 对于(int i=0;i,java,android,Java,Android,这是我的主要活动中按钮单击方法的代码。它只输出黑色图像。我使用alpha和不使用alpha,或者使用set pixel或set pixels。总是得到同样的结果 编辑:我的问题是使用复制方法时使用了错误的配置(我使用复制方法获取图像的可变位图),您需要的是ALPHA_8888,而不是ALPHA_8。这是您的格式。您将其设置为ALPHA_8。此格式仅存储alpha,不存储颜色数据。用户ARGB_8888-每个颜色通道8位,8位alpha。这是您的格式。您将其设置为ALPHA_8。此格式仅存储alp

这是我的主要活动中按钮单击方法的代码。它只输出黑色图像。我使用alpha和不使用alpha,或者使用set pixel或set pixels。总是得到同样的结果


编辑:我的问题是使用复制方法时使用了错误的配置(我使用复制方法获取图像的可变位图),您需要的是ALPHA_8888,而不是ALPHA_8。

这是您的格式。您将其设置为ALPHA_8。此格式仅存储alpha,不存储颜色数据。用户ARGB_8888-每个颜色通道8位,8位alpha。

这是您的格式。您将其设置为ALPHA_8。此格式仅存储alpha,不存储颜色数据。用户ARGB_8888-每个颜色通道8位和8位alpha

    TextView loadingText = (TextView)findViewById(R.id.loadingText);
    loadingText.setTextSize(36);
    loadingText.setText("Morphing...");
    Bitmap leftbm = ((BitmapDrawable)leftImage.getDrawable()).getBitmap();
    Bitmap rightbm = ((BitmapDrawable)rightImage.getDrawable()).getBitmap();


    Bitmap newbm = leftbm.copy(Bitmap.Config.ALPHA_8, true);
    int[] pixels = new int[newbm.getHeight() * newbm.getWidth()];
    newbm.getPixels(pixels, 0, newbm.getWidth(), 0, 0, newbm.getWidth(), newbm.getHeight());

    if (!newbm.isMutable()) {
        Log.d("mutable check", "" + newbm.isMutable());
        return;
    }

    for (int i = 0; i < newbm.getWidth(); i++) {
        for (int j = 0; j < newbm.getHeight(); j++) {
            newbm.setHasAlpha(false);
            newbm.setPixel(i, j, Color.rgb(0, 0, 255));
        }
    }

    loadingText.clearComposingText();
    ((ImageView)findViewById(R.id.morphView)).setImageBitmap(newbm);