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

Source: Internet
Author: User



The jar package is Commons-codec.jar.



Pnuts


//base64 is decoded into a picture
Function gldBase64ToImage(imgStr,imgFilePath) {
// Base64 decoding of byte array strings and generating images
     If ("".equals(imgStr) || imgStr == null) // Image data is empty
         Return false
        
//When transcoding, it may have a prefix format, so you need to split and take a valid string.
     imgArr = imgStr.split(",")
     If(imgArr.length == 1){
        imgStr = imgArr[0]
     }else{
         imgStr = imgArr[1]
     }
    
     imgByte = class org.apache.commons.codec.binary.Base64::decodeBase64(imgStr)

     // Base64 decoding
     For (i = 0; i < imgByte.length; ++i) {
         If (imgByte[i] < 0) {// Adjust the exception data
             imgByte[i] += 256;
         }
     }
     Out = class java.io.FileOutputStream(imgFilePath)
     Out.write(imgByte)
     Out.flush()
     Out.close()
} 


Java


/**
       * Base64 decoding of byte array strings and generating images
       * @param imgStr image data
       * @param imgFilePath save image full path address
       * @return
       */
      Public static boolean generateImage(String imgStr,String imgFilePath){
          //
          If ( "".equals(imgStr) || imgStr == null) //The image data is empty
              Return false;
      
          Try
          {
              //Base64 decoding
              Byte[] b = Base64.decodeBase64(imgStr);
              For(int i=0;i<b.length;++i)
              {
                  If(b[i]<0)
                  {//Adjust exception data
                      b[i]+=256;
                  }
              }
              / / Generate jpeg picture
 
              OutputStream out = new FileOutputStream(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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.