我尝试用宽高比调整图像的大小,就像下面的链接所做的那样
Resizing UIimages pulled from the Camera also ROTATES the UIimage?
https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more
这在模拟器上运行良好。但在我的iPhone-4上,图片的右边有一个黑色的方块。(图片的四分之一是黑色的)。这种情况只发生在imageOrientation right...so far的图片上。ImageOrientation up不会带来任何问题。
不知何故,我有一种感觉,CGBitmapContextCreate正在解决这个问题。我已经删除了CGImageGetBytesPerRow,因为它不能像我读到的那样工作。目前,我有以下代码:
if (sourceImage.imageOrientation == UIImageOrientationUp || sourceImage.imageOrientation == UIImageOrientationDown) {
bitmap = CGBitmapContextCreate(NULL, targetWidth, targetHeight, 8, 4*targetWidth, colorSpaceInfo, bitmapInfo);
} else {
bitmap = CGBitmapContextCreate(NULL, targetHeight, targetWidth, 8, 4*targetHeight, colorSpaceInfo, bitmapInfo);
}是什么导致了这些问题呢?
发布于 2011-06-28 05:27:06
我将使用此站点上的类别文件来调整UIImages的大小:
http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
https://stackoverflow.com/questions/6499111
复制相似问题