android - Image corrupted when sent via bluetooth -



android - Image corrupted when sent via bluetooth -

i developing client app in google glass takes image , sends byte array via bluetooth android phone has server app installed in it.

after sending info phone, tried create bitmap byte array , display in imageview. exact number of bytes sent received in server. when decode byte array create bitmap, image looks corrupted. overall image looks right there rectangular green/blue/red bars across image. lot, few. sometimes, lower part of image gray.

what issue here? or can seek find problem.

client code writing outputstream:

int buffersize = 512; bytebuffer bb = bytebuffer.allocate(buffersize); bb.aslongbuffer().put(bytes.length); mmoutstream.write(bb.array(), 0, buffersize); //write size of info sent first mmoutstream.write(bytes); //write actual byte info

server code reading inputstream (this in infinite while loop):

len = mminstream.read(buffer); if (len > 0) { bytebuffer bb = bytebuffer.wrap(buffer); bytestodownload = (int) bb.getlong(); totalbytes = 0; bytebuffer = bytebuffer.allocate(buffersize * buffersize * 2); while (totalbytes < bytestodownload) { len = mminstream.read(buffer); totalbytes += len; bytebuffer.put(buffer); outputstream.write(buffer, 0, len); } //display image bitmap bmp = bitmapfactory.decodebytearray(bytebuffer.array(), 0, totalbytes); imageview.setimagebitmap(bmp); }

update: when save completed image byte array filoutputstream, image looks perfect. have bitmapfactory.decodebytearray?

android image bluetooth byte google-glass

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -