title: How to display image in imageView from byte[], BitmapFactory.decodeByteArray returns null
body: <p>This is my first question on stackoverflow. </p>
  
  <p>My problem is: i'm trying to convert byte[] into image. The byte[] comes from JSON and it's in this format: </p>
  
  <p><code>"4oCwUE5HDQoaCgAAAA1JSERSAAAAfwAAAFAIBgAAADBHwqrDsAAAAAlwSFlzAAAAJwAAACcBKgnigJhPAAAgAElEQVR4xZPCrMK9ecWSZcOZfcOfw7c5w5vCvW/CqXp...</code>" it goes for another 100 lines. </p>
  
  <p>The code where the problem occurs: </p>
  
  <pre><code>DefaultHttpClient httpClient = new DefaultHttpClient();
          HttpPost httpPost = new HttpPost(PlayersListActivity.URL);
          httpPost.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
          HttpResponse httpResponse = httpClient.execute(httpPost);
          HttpEntity httpEntity = httpResponse.getEntity();
          BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(httpEntity);
          // if this is null the web service returned an empty page
          if(httpEntity == null) // response is empty so exit out
              return null;
  
          String jsonString = EntityUtils.toString(bufferedEntity);
  
          // again some simple validation around the returned string
          if(jsonString != null &amp;&amp; jsonString.length() != 0) // checking string returned from service to grab id
          {
              JSONArray jsonArray = new JSONArray(jsonString);
              for(int i=0; i&lt; jsonArray.length(); i++)
              {   
                  HashMap&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;();
  
                  JSONObject jsonObject = (JSONObject) jsonArray.get(i);
                  int id = jsonObject.getInt("id");
                  String name = jsonObject.getString("name");
                  byte[] images = jsonObject.getString("image").getBytes();
  
                  Bitmap btm = BitmapFactory.decodeByteArray(images, 0, images.length);
                  ByteArrayOutputStream stream = new ByteArrayOutputStream();
                  btm.compress(Bitmap.CompressFormat.PNG, 100, stream);
                  byte[] byteArray = stream.toByteArray();
  
                  Bitmap btm2 = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
                  ImageView image = (ImageView) findViewById(R.id.image);
                  image.setImageBitmap(btm2);
  
                  map.put("name", name.toString());
                  map.put("image", images.toString());
  
                  Log.d("JSON OBJECTS:", jsonObject.toString());
                  Log.d("WHATS IN MAP:", map.toString());
  
                  playersList.add(map);
  </code></pre>
  
  <p>And ofcourse error that I'm getting in LogCat: </p>
  
  <pre><code>SkImageDecoder:: Factory returned null.
  java.lang.NullPointerException
  </code></pre>
  
  <p>and it points out on this line:</p>
  
  <pre><code>Bitmap btm2 = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
  </code></pre>
  
  <p>I have done reseach but nothing really points on what I'm missing. 
  Any ideas?? </p>
  
  <p>Thanks!!</p>