iOS Development UI chapter-Creating a navigation controller and the life cycle of a controller using storyboard

Source: Internet
Author: User

Label:

The jar package is Commons-codec.jar.

Pnuts

//base64 decoding into picturesfunction Gldbase64toimage (imgstr,imgfilepath) {//Base64 decoding a byte array string and generating a picture    if("". Equals (IMGSTR) | | Imgstr = =NULL)//image data is empty        return false        
It may have a prefix format when transcoding, so it needs to be split to take a valid string Imgarr= Imgstr.split (",") if(Imgarr.length = =1) {Imgstr= imgarr[0] }Else{imgstr= imgarr[1]} imgbyte=classorg.apache.commons.codec.binary.Base64::d ecodeBase64 (IMGSTR)//Base64 decoding for(i =0; i < imgbyte.length; ++i) {if(Imgbyte[i] <0) {//Adjust Exception DataImgbyte[i] + = the; } } out=classJava.io.FileOutputStream (Imgfilepath) out. Write (Imgbyte) out. Flush () out. Close ()}

Java

 /** * Base64 decode byte array string and generate picture * @param imgstr picture data * @param imgfilepath Save picture Full path address * @return */      Public Staticboolean generateimage (String imgstr,string imgfilepath) {         //         if("". Equals (IMGSTR) | | Imgstr = =NULL)//image data is empty             return false;                   Try          {             //Base64 decoding             byte[] B =base64.decodebase64 (IMGSTR);              for(intI=0; i<b.length;++i)             {                 if(b[i]<0){//Adjust Exception Datab[i]+= the;                 }             }             //Create a JPEG pictureOutputStream out=NewFileOutputStream (Imgfilepath);               out. Write (b);              out. Flush ();              out. Close ();             return true;         }          Catch(Exception e)         {             return false;         }     }}

iOS Development UI chapter-Creating a navigation controller and the life cycle of a controller using storyboard

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: