title: Bitmap Compress giving empty file (0 bytes)
body: <p>EDIT - Another Udpate!</p>
  
  <p>Interestingly I tried the same code on my nexus 5, the image preview is correct but the image itself is just black.</p>
  
  <p>The devices being used are s3 minis, on these the image cannot be opened and no preview is displayed.</p>
  
  <p>I am aiming at sdk version 16.</p>
  
  <p>Further to this, I plugged my nexus back into my dev machine and opened as a storage device, image is not shown.</p>
  
  <p>I then emailed the image from my phone to myself and the bloody thing  displays fine, which has confused me either even further, the only thing I can think of is that the image is too big to display?</p>
  
  <p>////////////////////////////////////////////////////////////////////////////////////////////</p>
  
  <p>I am trying to create an image and then save it to file, it displays fine on screen and the file is created, however the file cannot be opened and has a size of 0 bytes. Has anyone had this problem before? This is my code:</p>
  
  <pre><code>private class SampleView extends View {
  
  
          public SampleView(Context context) {
              super(context);
              setFocusable(true);
  
          }
          @Override
          protected void onDraw(Canvas canvas) {
  
              EANMaker e = new EANMaker("123456789963");
              Paint paint = new Paint();
              View view = this;
              view.setDrawingCacheEnabled(true);
              view.setDrawingCacheQuality(view.DRAWING_CACHE_QUALITY_HIGH);
  
              canvas.drawColor(Color.WHITE);
  
  
              Bitmap b = Bitmap.createBitmap(500, 500, Bitmap.Config.ALPHA_8);
              Canvas c = new Canvas(b);
              c.drawRect(0, 0, 500, 500, paint);
              paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
              paint.setTextSize(40);
              paint.setTextScaleX(1.f);
              paint.setAlpha(0);
              paint.setAntiAlias(true);
              c.drawText("Carton ID", 60, 40, paint);
              paint.setTextSize(160);
              Typeface tf = gettypeFace(MyActivity.this, "ean.ttf");
              paint.setTypeface(tf);
              c.drawText(e.getCode(), 60, 180, paint);
              paint.setColor(Color.WHITE);
              canvas.drawBitmap(b, 50,50, paint);
  
              FileOutputStream fos = null;
              try {
                  fos = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/barcode.png");
                  b.compress(Bitmap.CompressFormat.PNG, 100, fos);
                  fos.flush();
                  fos.close();
                  fos = null;
              } catch (IOException ee) {
                  ee.printStackTrace();
              } catch (Exception p)
              {
                  p.printStackTrace();
              }
              finally {
                  if (fos != null) {
                      try {
                          fos.close();
                      } catch (IOException ee) {
                          ee.printStackTrace();
                      }
                  }
              }
          }
  
      }
  
      public Typeface gettypeFace(Context c, String assetPath) {
          synchronized (cache) {
              if (!cache.containsKey(assetPath)) {
                  try {
                      Typeface t = Typeface.createFromAsset(c.getAssets(),
                              assetPath);
                      cache.put(assetPath, t);
                  } catch (Exception e) {
                      Log.e("TAG", "Could not get typeface '" + assetPath
                              + "' because " + e.getMessage());
                      return null;
                  }
              }
              return cache.get(assetPath);
          }
      }
  </code></pre>
  
  <p>EDIT, I have been playing around with this and can now get a 6k file, however this still cannot be opened, I suspect that one of the canvases is not being drawn into the bitmap but I am at a complete loss on what else to do, my latest code is as follows</p>
  
  <pre><code>    private class SampleView extends View {
  
  
      public SampleView(Context context) {
          super(context);
          setFocusable(true);
  
      }
      @Override
      protected void onDraw(Canvas canvas) {
  
  
          EANMaker e = new EANMaker("123456789963");
          Paint paint = new Paint();
          canvas.drawColor(Color.WHITE);
          Bitmap b = Bitmap.createBitmap(900, 480, Bitmap.Config.ARGB_8888);
          Canvas c = new Canvas(b);
          canvas.drawBitmap(b,0,0, paint);
  
          //paint.setTextScaleX(1.f);
  
          paint.setColor(Color.BLACK);
          paint.setTextSize(40);
          c.drawText("Carton LABEL", 20, 40, paint);
          c.drawText("Carton ID = 1      Packed By = Test User", 20, 80, paint);
          c.drawText("Despatch Date = 05/08/2014", 20, 120, paint);
          paint.setTextSize(160);
          Typeface tf = gettypeFace(MyActivity.this, "ean.ttf");
          paint.setTypeface(tf);
          c.drawText(e.getCode(), 60, 280, paint);
          paint.setColor(Color.WHITE);
  
  
          FileOutputStream fos = null;
          try {
              fos = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/barcode.png");
              b.compress(Bitmap.CompressFormat.PNG, 80, fos);
              fos.flush();
              fos.close();
              fos = null;
          } catch (IOException ee) {
              ee.printStackTrace();
          } catch (Exception p)
          {
              p.printStackTrace();
          }
          finally {
              if (fos != null) {
                  try {
                      fos.close();
                  } catch (IOException ee) {
                      ee.printStackTrace();
                  }
              }
          }
  
      }
  
  }
  
  public Typeface gettypeFace(Context c, String assetPath) {
      synchronized (cache) {
          if (!cache.containsKey(assetPath)) {
              try {
                  Typeface t = Typeface.createFromAsset(c.getAssets(),
                          assetPath);
                  cache.put(assetPath, t);
              } catch (Exception e) {
                  Log.e("TAG", "Could not get typeface '" + assetPath
                          + "' because " + e.getMessage());
                  return null;
              }
          }
          return cache.get(assetPath);
      }
  }
  </code></pre>
  
  <p>and my logcat to prove there is no errors:</p>
  
  <pre><code>08-05 13:13:02.371  26627-26627/com.example.imagetest I/System.out﹕ debugger has settled (1443)
  08-05 13:13:03.082  26627-26627/com.example.imagetest D/libEGL﹕ loaded /system/lib/egl/libEGL_mali.so
  08-05 13:13:03.082  26627-26627/com.example.imagetest D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_mali.so
  08-05 13:13:03.092  26627-26627/com.example.imagetest D/libEGL﹕ loaded /system/lib/egl/libGLESv2_mali.so
  08-05 13:13:03.112  26627-26627/com.example.imagetest D/OpenGLRenderer﹕ Enabling debug mode 0
  08-05 13:13:03.162  26627-26627/com.example.imagetest I/System.out﹕ Full code: 1234567899633
  08-05 13:13:03.162  26627-26627/com.example.imagetest I/System.out﹕ Generated code: $!23E5GH-ijjgdd!
  08-05 13:13:03.192  26627-26627/com.example.imagetest D/dalvikvm﹕ GC_FOR_ALLOC freed 84K, 13% free 9464K/10823K, paused 22ms, total 32ms
  08-05 13:13:03.192  26627-26627/com.example.imagetest I/dalvikvm-heap﹕ Grow heap (frag case) to 12.093MB for 1728016-byte allocation
  08-05 13:13:03.222  26627-26629/com.example.imagetest D/dalvikvm﹕ GC_CONCURRENT freed 39K, 12% free 11112K/12551K, paused 13ms+3ms, total 31ms
  08-05 13:13:03.222  26627-26627/com.example.imagetest D/dalvikvm﹕ WAIT_FOR_CONCURRENT_GC blocked 9ms
  </code></pre>