0

i want to get exacly bitmap show on screen after(scale,filtercolor,...) and work with its pixel for example in order to remove transparent pixel :

 for (int y = 0; y < sourceBitmap1.getHeight(); y++) 
        for (int x = 0; x < sourceBitmap1.getWidth(); x++) 
            if (sourceBitmap1.getPixel(x, y) == Color.TRANSPARENT) {
                  //todo do something
            }

but it is important to get bitmap related to target Imageview. as i see other post can do this with this method:

 public static Bitmap loadBitmapFromView(ImageView i) {
    i.setDrawingCacheEnabled(true);
    i.measure(FrameLayout.MeasureSpec.makeMeasureSpec(0,   FrameLayout.MeasureSpec.UNSPECIFIED),
            FrameLayout.MeasureSpec.makeMeasureSpec(0,    FrameLayout.MeasureSpec.UNSPECIFIED));
    i.layout(0, 0, i.getMeasuredWidth(), i.getMeasuredHeight());
    i.buildDrawingCache(true);
    Bitmap b = Bitmap.createBitmap(i.getDrawingCache(true));
    i.setDrawingCacheEnabled(false);
    return b;
}

but method return null , any idea? thanks in advanced

FxRi4
  • 1,060
  • 10
  • 14

1 Answers1

0

try this to get bitmap from imageview

 Bitmap bitmap = ((BitmapDrawable) imgview.getDrawable()).getBitmap();
Manish Menaria
  • 17,647
  • 3
  • 18
  • 23
  • i check this not return scaled bitmap ,this return exacly drawable bitmap consider drawble bitmap is 500*500 but imageview bitmap is 200*200 it return 500*500 drawble – FxRi4 Jun 18 '16 at 10:59