gpt4 book ai didi

iphone - 按纵横比调整图像大小

转载 作者:行者123 更新时间:2023-12-03 21:06:37 24 4
gpt4 key购买 nike

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

Resizing UIimages pulled from the Camera also ROTATES the UIimage?

https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more

这在模拟器上运行良好。但在我的 iPhone-4 上,我在图片右侧看到一个黑色 block 。 (图片的第四张是黑色的)。到目前为止,这只发生在 imageOrientation 正确的图片上。 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);
}

什么会导致这些问题?

最佳答案

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

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

关于iphone - 按纵横比调整图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6499111/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com