Abrufen der Größe eines Bildinputstreams

Ich muss die Höhe und Breite des im Inputstream gefundenen Bildes ermitteln. Folgendes habe ich getan:

private Boolean testSize(InputStream inputStream){
        BitmapFactory.Options Bitmp_Options = new BitmapFactory.Options();
        Bitmp_Options.inJustDecodeBounds = true;
        BitmapFactory.decodeResourceStream(getResources(), new TypedValue(), inputStream, new Rect(), Bitmp_Options);
        int currentImageHeight = Bitmp_Options.outHeight;
        int currentImageWidth = Bitmp_Options.outWidth;
        Bitmp_Options.inJustDecodeBounds = false;
    if(currentImageHeight < 200 || currentImageWidth < 200){
        Object obj = map.remove(pageCounter);
        Log.i("Page recycled", obj.toString());
        return true;
    }
    return false;}

Überspringen zum Problem an der Stelle:

Es ändert BitmapFactory.Options, auch wenn ich es nach der Berechnung mit meiner zweiten Methode unten zwang, falsch zu sein.

private Bitmap getBitmap(InputStream InpStream){
    Bitmap originalBitmap = BitmapFactory.decodeStream(InpStream);//Null.
    return originalBitmap;
}

Nun zu meiner Frage, gibt es eine andere Möglichkeit, die Größe und Breite eines Bildes von einem Inputstream zu erhalten? Ich brauche wirklich Hilfe, jede Hilfe wird sehr geschätzt.

                ZipInputStream zip = null;
                zip = new ZipInputStream(new FileInputStream(getFileLocation()));
                for(ZipEntry zip_e = zip.getNextEntry(); zip_e != null ; zip_e = zip.getNextEntry()){
                    if(zip_e.isDirectory()) {
                        continue;
                    }
                    String file_zip = zip_e.getName();
                    String comparison = map.get(pageCounter).getHref();
                    if(file_zip.endsWith(comparison)){
                        SpannableString Spanable_String = new SpannableString("abc");
                        if(testSize(zip)){
                            map.remove(pageCounter);
                            return false;
                        }
                        Bitmap bitmap = getBitmap(zip);
                        if(bitmap == null){
                            map.remove(pageCounter);
                            return false;
                        }
                        image_page.put(zip_e.getName(), zip);
                        Drawable drawable_image = new FastBitmapDrawable(bitmap);
                        drawable_image.setBounds(0,0,drawable_image.getIntrinsicWidth(), drawable_image.getIntrinsicHeight());
                        ImageSpan imageSpan = new ImageSpan(drawable_image, ImageSpan.ALIGN_BASELINE);
                        Spanable_String.setSpan(imageSpan, 0, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                        tv.setText(Spanable_String);
                        return false;
                    }
                }   

Antworten auf die Frage(1)

Ihre Antwort auf die Frage