繁体   English   中英

CGImageRef to UIImage可以在模拟器或设备上的iOS 4上调试照片

[英]CGImageRef to UIImage rotates my photos debugging on a iOS 4 in simulator or device

我对一些简单的代码有疑问。 相机拍摄或拍摄的照片被旋转。 起初我以为这是UIView中的设置,但是当我使用CGImageRef将传入的UIImage复制到另一个UIImage时会发生这种情况。 我这样做是因为这是确保使用副本的最简单方法。 如果我搞砸了,请更正此代码。

代码:

- (id)initWithImage:(UIImage *)image {
    if ((self = [super init]) && (image != nil)) {
        CGImageRef tmpImageRef = [image CGImage];
        puzzle = [[UIImage alloc] initWithCGImage:tmpImageRef];
    }

    return self;
}

调试器:

    This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001
Loading program into debugger…
sharedlibrary apply-load-rules all
Program loaded.
target remote-mobile /tmp/.XcodeGDBRemote-25694-49
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
run
Running…
[Switching to thread 11523]
[Switching to thread 11523]
Re-enabling shared library breakpoint 1
Re-enabling shared library breakpoint 2
continue
2010-07-13 15:09:17.159 Golovomka[693:307] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
2010-07-13 15:09:17.172 Golovomka[693:307] Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate
Current language:  auto; currently objective-c
(gdb) print (CGSize)[image size]
$1 = {
  width = 1536, 
  height = 2048
}
(gdb) n
28                  puzzle = [[UIImage alloc] initWithCGImage:tmpImageRef];
(gdb)
31          return self;
(gdb) print (CGSize)[puzzle size]
$2 = {
  width = 2048,
  height = 1536
}
(gdb)

第一次打印在CGIMageRef实例化行上。 非常感谢任何帮助。 如我所说,这不会在模拟器中发生,只有在将代码部署到实际设备上时才会发生。 请注意,这篇文章曾经说过,该问题仅发生在设备上调试,而不是模拟器中。 从那以后,我将用iPhone 3gs上的相机拍摄的照片复制到模拟器中,结果完全一样。 因此,如果周围有2048x1536图片,您应该可以在SIM卡中复制该图片。

从UIImage提取CGImage时,UIImage的方向属性会被忽略。 您应该这样做:

if (self = [super init]) {
    puzzle = image; 
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM