32

में इनपुट स्ट्रीम को कनवर्ट करना मुझे वेब से बिटमैप में इनपुट स्ट्रीम को परिवर्तित करने में समस्याएं हैं। समस्या तब होती है जब इनपुट छवि प्रकार है .BMP (बिटमैप)। उस स्थिति में: bitmapFactory.decodeStream शून्य देता है।बिटमैप

कोई समस्या बताती है कि इस समस्या को कैसे ठीक किया जाए या मुझे अपनी डीबगिंग कहां जारी रखनी चाहिए?

प्लेटफार्म: एंड्रॉयड (Honeycomb)

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

inputStream = conn.getInputStream(); 

bufferedInputStream = new BufferedInputStream(inputStream); 

bmp = BitmapFactory.decodeStream(bufferedInputStream); 
+1

वहाँ मदद कर सकते हैं की तुलना में किसी भी लॉग त्रुटि कर रहे हैं? –

उत्तर

41

बाहर बिंदु लॉग के लिए आप @Amir धन्यवाद। एक पंक्ति का पता चला:

decoder->decode returned false 

यह एक आम समस्या प्रतीत होती है। एक खोज करना मुझे एक समाधान मिला।

मेरे पिछले कोड:

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

inputStream = conn.getInputStream(); 

bufferedInputStream = new BufferedInputStream(inputStream); 

bmp = BitmapFactory.decodeStream(bufferedInputStream); 

कोड जो काम कर रहा है:

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); 

Source

+0

आप किस सेवा का उपयोग करते हैं? –

+0

मैं डब्ल्यूसीएफ सेवा का उपयोग करता हूं और जब मैं छवि के बाइट [] भेजता हूं और बिटमैप छवि में वापस कनवर्ट करने के लिए अपनी विधि का उपयोग करता हूं, लेकिन बिटमैपफैक्टरी.decodeStream (instream) हमेशा शून्य है !! –

संबंधित मुद्दे