0
我目前正在替換UIGetScreenImage()在我的代碼中,因爲它導致C99錯誤。裁剪UIImage屏幕截圖
我將其替換爲this code from apple,其中screenshot
方法返回UIImage
。是
我在裁剪並保存圖像嘗試如下:
UIImage *returnedImage = [self screenshot];
// Get image to save
CGImageRef screen = returnedImage.CGImage;
UIImage *img = [UIImage imageWithCGImage:screen];
// Image cropping
CGImageRef imageRef = CGImageCreateWithImageInRect([img CGImage], CGRectMake(0, 5, 768, 1004));
UIImage *img2Save = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
// Request to save the image to camera roll
UIImageWriteToSavedPhotosAlbum(img2Save, self, nil, nil);
我也試圖在screenshot
方法種植前把它返回它,但無濟於事。
保存從screenshot
方法返回的兩個嘗試中未返回的未修改的UIImage
。
有什麼明顯的我離開了嗎?我曾看過this SO thread,但無法看到連接。
嗨@neon samuel,我試圖從其他線程調用該函數。會發生什麼似乎是翻轉圖片並縮小圖像。這是由於我傳遞給它的座標嗎?我不認爲它會因爲我傳遞給該方法的前兩個參數是0而失敗。 –