首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用纵横比调整图像大小

使用纵横比调整图像大小
EN

Stack Overflow用户
提问于 2011-06-28 05:23:13
回答 1查看 2.3K关注 0票数 2

我尝试用宽高比调整图像的大小,就像下面的链接所做的那样

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,因为它不能像我读到的那样工作。目前,我有以下代码:

代码语言:javascript
复制
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);
}

是什么导致了这些问题呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-28 05:27:06

我将使用此站点上的类别文件来调整UIImages的大小:

http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6499111

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档