IOS picture conversion binary binary binary conversion to picture

Source: Internet
Author: User

//class method picture converted to binary+ (NSData *) Image_transform_data: (UIImage *) image{NSData*imagedata = uiimagejpegrepresentation (image,0.5);
//almost 0.5 of the image size to the original half of it, like here 24KB to 11KB returnImageData;}//examples of calling methods-(void) Viewwillappear: (BOOL) animated{[self read_imagedata];}- (void) viewdidload{Nav_view=[[Navview alloc]init]; [Self.view addsubview: [Nav_view navview_title:@"Announcements"]]; [Super Viewdidload]; [Self read_imagedata];}//The following method is to compress a picture into binary and then converted to a picture to do a good job-(void) read_imagedata{Uiimageview*imageview1=[[uiimageview Alloc]initwithframe:cgrectmake (0, the, $, $)]; Imageview1.image=[uiimage imagenamed:@"Cat_food.png"]; [Self.view Addsubview:imageview1]; Uiimageview*imageview3=[[uiimageview Alloc]initwithframe:cgrectmake (0,280, $, $)]; Imageview3.image=[UIImage imagewithdata:[function Image_TransForm_Data:imageView1.image]; [Self.view ADDSUBVIEW:IMAGEVIEW3]; NSData*data =[NSData datawithdata:[function Image_TransForm_Data:imageView1.image]; [Data writetofile:[function Createthefolder_from:library_cache fileholdername:myfolder FileName:@"Pp111111.png"] atomically:yes];}

: as follows

Can see a little compressed quality details is not okay haha

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.