Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to display bitmap pixel by pixel?
    primarykey
    data
    text
    <p>i am trying to display a bitmap image pixel by pixel (which explicitly means with some delay). i am using two "for" loops to do that but it prints only a single row of pixel...... if anyone has any idea on how to do???? Pls help..... my code is this........</p> <pre><code>Button start = (Button) findViewById(R.id.start); start.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Toast.makeText(getBaseContext(), "Printing...", Toast.LENGTH_SHORT).show(); iImageArray = new int[bMap.getWidth()* bMap.getHeight()]; //initializing the array for the image size bMap.getPixels(iImageArray, 0, bMap.getWidth(), 0, 0, bMap.getWidth(), bMap.getHeight()); //copy pixel data from the Bitmap into the 'intArray' array //Canvas canvas = new Canvas (bMap); //replace the red pixels with yellow ones for (int i=0; i &lt; bMap.getHeight(); i++) { for(int j=0; j&lt;bMap.getWidth(); j++) { iImageArray[j] = 0xFFFFFFFF; } } bMap = Bitmap.createBitmap(iImageArray, bMap.getWidth(), bMap.getHeight(), Bitmap.Config.ARGB_8888);//Initialize the bitmap, with the replaced color image.setImageBitmap(bMap); //canvas.drawPoints(iImageArray, 0, bMap.getHeight()*bMap.getWidth(), paint); } }); </code></pre> <p>and i want to print the bitmap in grayscale and for that i found this code....</p> <pre><code> public Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight(); width = bmpOriginal.getWidth(); Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); Canvas c = new Canvas(bmpGrayscale); Paint paint = new Paint(); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm); paint.setColorFilter(f); c.drawBitmap(bmpOriginal, 0, 0, paint); return bmpGrayscale; } </code></pre> <p>iImageArray[i] = 0xFFFFFFFF; i have this to test, not the actual grayscale value.....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload