tarjeta reparar reconocida reconocer reconoce que porque para micro memoria lea hago funciona detecta dejo dañada como celular android image imageview thumbnails

reparar - Android: Lea la imagen como el pulgar en tiempo de ejecución



reparar tarjeta sd no reconocida android (4)

El truco popular es muestrear la imagen original omitiendo algunos píxeles. Código algo optimizado (miniatura en miniatura solamente):

public static Bitmap getImageThumbnail(String filePath, int size) { Options queryOPs = queryBitmap(filePath); int imgSize = Math.max(queryOPs.outWidth, queryOPs.outHeight); imgSize = Math.max(imgSize, size); int sampleSize = 1; while (imgSize / (sampleSize * 2) > size) { sampleSize *= 2; } Options decodeOps = new Options(); decodeOps.inSampleSize = sampleSize; Bitmap img = BitmapFactory.decodeFile(filePath, decodeOps); if (img == null) { return null; } Bitmap thumb = Bitmap.createBitmap(size, size, Bitmap.Config.RGB_565); Canvas can = new Canvas(thumb); Paint pnt = new Paint(Paint.DITHER_FLAG); can.drawBitmap(img, 0, 0, pnt); return thumb; } private static Options queryBitmap(String filePath) { Options ops = new Options(); ops.inJustDecodeBounds = true; BitmapFactory.decodeFile(filePath, ops); return ops; }

Para una galería personalizada que estoy creando usando una vista de cuadrícula con imageviews, deseo leer una imagen del almacenamiento sd. Esto me da enormes problemas de rendimiento, ya que leerá toda la imagen y la cargará en la vista de la imagen.

  • ¿Cómo puedo leer una imagen grande como un pulgar en tiempo de ejecución con énfasis en el rendimiento?

    File imgFile = new File(img.getInternalImagePath()); if(imgFile.exists()){ Bitmap myBitmap; try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 4; myBitmap = BitmapFactory.decodeStream(new FlushedInputStream(new FileInputStream(imgFile)),null,options); picture.setImageBitmap(myBitmap);

Gracias por adelantado.

/ Andy

EDITAR: Agregó un código para mirar



final int THUMBNAIL_SIZE = 64; FileInputStream fis = new FileInputStream(fileName); Bitmap imageBitmap = BitmapFactory.decodeStream(fis); imageBitmap = Bitmap.createScaledBitmap(imageBitmap, THUMBNAIL_SIZE, THUMBNAIL_SIZE, false); ByteArrayOutputStream baos = new ByteArrayOutputStream(); imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); imageData = baos.toByteArray();

O

Bitmap thumbBitmap = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(filePath), thumbWidth, thumbHeight);


@Override public View getView(final int position, View view, ViewGroup parent) { pos = position; View v = view; RecordHolder holder = null; LayoutInflater mInflater = (LayoutInflater) mContext .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); if (v == null) { v = mInflater.inflate(R.layout.items, parent, false); holder = new RecordHolder(); holder.imagev = (ImageView) v.findViewById(R.id.imag_v); v.setTag(holder); } else { holder = (RecordHolder) v.getTag(); } BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 6; Bitmap bitmap1 = BitmapFactory.decodeResource(v.getResources(), items.get(position), options); holder.imagev.setImageBitmap(bitmap1);

}}