Konwersja strumienia wejściowego na bitmapę

Mam problemy z konwersją strumienia wejściowego z web na bitmapę. Problem występuje tylko wtedy, gdy wejściowy typ obrazu jest .BMP (bitmap). W takim przypadku: bitmapFactory.decodeStream zwraca null .

Jakieś wskazówki jak rozwiązać ten problem lub gdzie mam kontynuować debugowanie?

Platforma: Android (Honeycomb)

URLConnection conn = url.openConnection();
conn.connect();

inputStream = conn.getInputStream();

bufferedInputStream = new BufferedInputStream(inputStream);

bmp = BitmapFactory.decodeStream(bufferedInputStream);
Author: Indrek Kõue, 2011-07-07

1 answers

Dziękuję @Amir za wskazanie dziennika. Odkrył linię:

decoder->decode returned false
To wydaje się być częstym problemem. Szukając znalazłem rozwiązanie.

Mój poprzedni kod:

URLConnection conn = url.openConnection();
conn.connect();

inputStream = conn.getInputStream();

bufferedInputStream = new BufferedInputStream(inputStream);

bmp = BitmapFactory.decodeStream(bufferedInputStream);

Kod który działa:

HttpGet httpRequest = null;

try {
    httpRequest = new HttpGet(url.toURI());
} catch (URISyntaxException e) {
    e.printStackTrace();
}

HttpClient httpclient = new DefaultHttpClient();

HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);

HttpEntity entity = response.getEntity();

BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);

InputStream instream = bufHttpEntity.getContent();

bmp = BitmapFactory.decodeStream(instream);

Źródło

 48
Author: Indrek Kõue,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-07-08 07:55:31