List of usage examples for android.widget ImageView getDrawable
public Drawable getDrawable()
From source file:Main.java
public static void stripImageView(ImageView view) { if (view.getDrawable() instanceof BitmapDrawable) { ((BitmapDrawable) view.getDrawable()).getBitmap().recycle(); }//w w w .ja v a 2 s. c om view.getDrawable().setCallback(null); view.setImageDrawable(null); view.getResources().flushLayoutCache(); view.destroyDrawingCache(); }
From source file:Main.java
public static void cleanImageView(ImageView imageView) { if (!(imageView.getDrawable() instanceof BitmapDrawable)) return;// www . ja v a 2 s . com //Clean up the view's image for the sake of memory BitmapDrawable b = (BitmapDrawable) imageView.getDrawable(); b.getBitmap().recycle(); imageView.setImageDrawable(null); }
From source file:Main.java
public static void cleanImageView(ImageView imageView) { if (!(imageView.getDrawable() instanceof BitmapDrawable)) return;// w ww .ja v a 2 s . c o m // clean up the view's image for the sake of memory BitmapDrawable b = (BitmapDrawable) imageView.getDrawable(); b.getBitmap().recycle(); imageView.setImageDrawable(null); }
From source file:Main.java
public static void clearImageView(ImageView imageView) { if (!(imageView.getDrawable() instanceof BitmapDrawable)) { return;//from w w w .j av a 2s. c o m } Bitmap drawable = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); if (drawable != null && !drawable.isRecycled()) { drawable.recycle(); } imageView.setImageDrawable(null); }
From source file:Main.java
/** * Cleans up view's image to reduce memory cost to device * @param imageView// w ww . j a va 2s . c o m */ static void cleanImageView(ImageView imageView) { if (!(imageView.getDrawable() instanceof BitmapDrawable)) return; // clean up the view's image for the sake of memory BitmapDrawable b = (BitmapDrawable) imageView.getDrawable(); b.getBitmap().recycle(); imageView.setImageDrawable(null); }
From source file:Main.java
public static String base64Encode(ImageView imageView) { if (imageView.getDrawable() != null) { Bitmap avatarBitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); avatarBitmap.compress(Bitmap.CompressFormat.PNG, 70, baos); byte[] avatarByteArray = baos.toByteArray(); return Base64.encodeToString(avatarByteArray, Base64.DEFAULT); } else {//w w w.j av a2 s.c o m return null; } }
From source file:Main.java
public static Bitmap getBitmapFromImageView(ImageView imageView) { return ((BitmapDrawable) imageView.getDrawable()).getBitmap(); }
From source file:Main.java
public static void setIconColor(ImageView icon, int color) { Drawable iconDrawable = icon.getDrawable(); icon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); icon.setImageDrawable(iconDrawable); }
From source file:Main.java
public static int[] mapBitmapCoordinatesFromImageView(int posX, int posY, ImageView imageView) { Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); int ivW = imageView.getWidth(); int ivH = imageView.getHeight(); int bW = bitmap.getWidth(); int bH = bitmap.getHeight(); int newX = posX * bW / ivW; int newH = posY * bH / ivH; return new int[] { newX, newH }; }
From source file:Main.java
public static byte[] ImageToByte(ImageView image) { Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap(); Bitmap resized = Bitmap.createScaledBitmap(bitmap, 150, 150, true); ByteArrayOutputStream baos = new ByteArrayOutputStream(); resized.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos.toByteArray(); }