0
爲了創建一個矩陣和操縱圖像的像素,我應該將圖像轉換爲位圖? 我的應用程序是關於從相機或庫中拍攝照片,當我觸摸圖像的一部分時,圖像的這個區域應該伸展。 這裏是我累了的UIImage轉換爲位圖的代碼:UIImage操作IOS
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(-20, -20, -20, -20);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
imageView.image = [[UIImage imageNamed:@"number1.png"] resizableImageWithCapInsets:edgeInsets];
[self.view addSubview:imageView];
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 0.0);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *bmImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSArray *documentsPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentsPaths objectAtIndex:0];
[UIImagePNGRepresentation(bmImage) writeToFile:[documentsDir stringByAppendingString:@"num1.png"] atomically:YES];
感謝您的幫助
那麼,你的問題是什麼?如何拉伸圖像的一部分?你能否提供你想要達到的目標的例子? – sergio
這是圖像的鏈接,解釋我想要做什麼http://postimg.org/image/ldy7q9lgt/ 圖像是從圖書館採取的。問題是我想操縱透明遮罩內的像素。我現在可以從庫中選擇一個圖像並顯示該透明度蒙版。我應該將圖像轉換爲位圖來操縱我的像素嗎? – user3218885