title: android BitmapFactory.decodeStream low quality
body: <p>I'm trying to decode an inputstream to bitmap, the code is so simple :</p>
  
  <pre><code>Bitmap myBitmap = BitmapFactory.decodeStream(myStream);
  </code></pre>
  
  <p>BUT the quality of outputed bitmap is too low (<strong>sometimes</strong>, and sometimes the quality is good). </p>
  
  <p>also the source has a good quality image.</p>
  
  <p>i tried to play with Bitmap options but nothing changed:</p>
  
  <pre><code>BitmapFactory.Options options = new BitmapFactory.Options();
  options.inScaled = false;
  options.inDither = false;
  options.inPreferredConfig = Bitmap.Config.ARGB_8888;
  Bitmap myBitmap = BitmapFactory.decodeStream(myStream, null, options);
  </code></pre>
  
  <p>so, how can i get the full quality bitmap?</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>I use this picture for an animation, like below:</p>
  
  <pre><code>coverAnimationImage.post(new Runnable()
  {
      Override
      public void run()
      {
          try
          {
              InputStream coverStream = getCoverStream();
              if(coverStream != null)
              {
                  bookCover = BitmapFactory.decodeStream(coverStream);
              }
          }
          catch (Exception e)
          {
              //  no cover
          }
          coverAnimationImage.setImageBitmap(bookCover);
          mBackground = new ColorDrawable(Color.BLACK);
          if(Build.VERSION.SDK_INT &gt;= 16)
          {
              coverAnimationLayout.setBackground(mBackground);
          }
          else
          {
             coverAnimationLayout.setBackgroundDrawable(mBackground);
          }
          if (flag)
          {
              ViewTreeObserver observer = coverAnimationImage.getViewTreeObserver();
              observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener()
              {
                  @Override
                  public boolean onPreDraw()
                  {
                      coverAnimationImage.getViewTreeObserver().removeOnPreDrawListener(this);
                      int[] screenLocation = new int[2];
                      coverAnimationImage.getLocationOnScreen(screenLocation);
                      mLeftDelta = coverLeft - (screenLocation[0]);
                      mTopDelta = coverTop - (screenLocation[1]);
                      mWidthScale = (float) coverWidth / coverAnimationImage.getWidth();
                      mHeightScale = (float) coverHeight / coverAnimationImage.getHeight();
                      runEnterAnimation();
                      return true;
                  }
              });
          }
      }
  });
  </code></pre>
  
  <p>I think when i run the animation the <code>BitmapFactory.decodeStream</code> isn't finished it's job! is it possible? or any idea whats happening here?</p>
  
  <p><strong>Update 2:</strong> the image info</p>
  
  <p><img src="https://i.stack.imgur.com/3P06E.jpg" alt="enter image description here"></p>
  
  <p><strong>Update 3:</strong></p>
  
  <p>low quality image:</p>
  
  <p><img src="https://i.stack.imgur.com/4gTIF.jpg" alt="enter image description here"></p>
  
  <p>high quality:</p>
  
  <p><img src="https://i.stack.imgur.com/8jVsP.jpg" alt="enter image description here"></p>
  
  <p>memory monitor:</p>
  
  <p><img src="https://i.stack.imgur.com/BV748.jpg" alt="enter image description here"></p>
  
  <p>YouTube Video:</p>
  
  <p><a href="https://youtu.be/iCUYE_zIFf4" rel="nofollow noreferrer">android BitmapFactory.decodeStream low quality
  </a></p>
  
  <p><strong>Update 4:</strong></p>
  
  <p>the code of <code>getCoverStream</code> :</p>
  
  <pre><code>protected InputStream getCoverStream() 
  {    
      String fileName = getCoverAddress();
      InputStream in = null;
      ZipEntry containerEntry = mZip.getEntry(fileName);
      if (containerEntry != null) 
      {
          try 
          {
              in = mZip.getInputStream(containerEntry);
          } 
          catch (IOException e) 
          {
              Log.e(TAG, "Error reading zip file " + fileName, e);
          }
      }
  
      if (in == null) 
      {
          Log.e(TAG, "Unable to find file in zip: " + fileName);
      }
  
      return in;
  }
  </code></pre>