As you can see, although it is a JPG file, it is essentially a motion diagram.
But found in our picture module, the local storage of images only one frame, the problem is where?
Byte[] Data obtained by HTTP is no problem.
Breakpoint tracking, found that the problem occurred in the last sentence when compressing the size of the picture.
Public StaticBitmap Getscaledbitmap (byte[] Data,intWidthintheight) {bitmapfactory.options Options=Newbitmapfactory.options (); Options.injustdecodebounds=true; Bitmapfactory.decodebytearray (data,0, data.length, Options); floatSrcwidth =Options.outwidth; floatSrcheight =Options.outheight; intInsamplesize = 1; if(Srcheight > Height | | srcwidth >width) { if(Srcwidth >srcheight) Insamplesize= Math.Round (Srcheight/height); Elseinsamplesize= Math.Round (Srcwidth/width); } Options=Newbitmapfactory.options (); Options.insamplesize=insamplesize; returnBitmapfactory.decodebytearray (data, 0, data.length, Options); }
The final solution is to write to the local HTTP byte[] data without bitmap, and then compress the image size when it is removed.
/*** Write Bytes * *@paramURL *@parambytes *@return */ Public BooleanSave (String URL,byte[] bytes) { if(bytes = =NULL|| Bytes.length = = 0) return false; URL=trans2local (URL); File File=NewFile (URL); if(File.exists ())return true; Zio.createnewfile (file); FileOutputStream Fos=NULL; Try{fos=Newfileoutputstream (file); Fos.write (bytes); return true; } Catch(Exception e) {e.printstacktrace (); LOG.E ("Storage Error", E.getmessage ()); } finally { Try{fos.close (); } Catch(Exception e) {e.printstacktrace (); } } return false; }
The extra benefit of this approach is to ignore the bizarre picture format quality issues.
For example, when we save the picture with the bitmap to take the judging picture type, but also to specify the compression accuracy (if 100, the picture size is much larger than the original, it is Strange)
Bitmap.compressformat format = Url.tolowercase (). IndexOf ("PNG") > 0? Bitmap.CompressFormat.PNG:Bitmap.CompressFormat.JPEG; , FOS);
"Android" How to download GIF images to local