I'm starting with Android and I work on Image processing. I would like to create a grid with random black and white pixels. I tried with bitmap but I don't really get how it works.
I tried with the following code but it says: The type of the expression must be an array type but it resolved to Matrix
Even without this error, I'm not sure that this is the right way to proceed. So if you have any ideas ...
Thank you !
import java.util.Random;
import android.support.v7.app.ActionBarActivity;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends ActionBarActivity {
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img = (ImageView)findViewById(R.id.imageView1);
}
public void RandomImage (View view)
{
Random rand = new Random();
Matrix mat = new Matrix();
for (int i=0; i<100; i++)
{
for (int j=0; j<100 ; j++)
{
mat[i][j]=rand.nextInt(1);
img.setImageMatrix(mat);
}
}
}
}