IOS 圖片轉換二進位 二進位轉換為圖片

來源:互聯網
上載者:User

標籤:style   class   blog   code   http   color   

//類方法  圖片 轉換為二進位+(NSData *)Image_TransForm_Data:(UIImage *)image{    NSData *imageData = UIImageJPEGRepresentation(image , 0.5);
//幾乎是按0.5圖片大小就降到原來的一半 比如這裡 24KB 降到11KB return imageData;}//調用方法舉例-(void)viewWillAppear:(BOOL)animated{ [self Read_ImageData];}- (void)viewDidLoad{ nav_View=[[NavView alloc]init]; [self.view addSubview: [nav_View NavView_Title:@"通告"]]; [super viewDidLoad]; [self Read_ImageData];}//以下方法 就是把一圖片壓縮成二進位 再轉換成圖片做顯示 效果 不錯-(void)Read_ImageData{ UIImageView *imageView1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 80, 200, 200)]; imageView1.image=[UIImage imageNamed:@"cat_food.png"]; [self.view addSubview:imageView1]; UIImageView *imageView3=[[UIImageView alloc]initWithFrame:CGRectMake(0, 280, 200, 200)]; 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];}

:如下

能看到一點被壓縮品質的細節是不是 還好哈哈

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.