【问题标题】:How to save iphone screen shot as jpeg image?如何将iphone屏幕截图保存为jpeg图像?
【发布时间】:2010-04-05 16:56:40
【问题描述】:

我正在开发一个应用程序,我需要将 iPhone 屏幕截图的一部分保存为 JPEG,然后通过电子邮件发送。屏幕部分有一些文本标签、字段等。请提供有关如何将屏幕部分保存为 JPEG 的任何想法(我是新手,因此非常感谢任何帮助/示例代码)

【问题讨论】:

    标签: cocoa-touch iphone-sdk-3.0 cocos2d-iphone


    【解决方案1】:

    以下代码会将视图的内容保存到用户的照片库中。您应该能够修改它以便能够通过电子邮件发送文件。

      CGRect myRect = [myView bounds];
      UIGraphicsBeginImageContext(myRect.size);
    
      CGContextRef ctx = UIGraphicsGetCurrentContext();
      [[UIColor blackColor] set];
      CGContextFillRect(ctx, myRect);
    
      [myView.layer renderInContext:ctx];
    
      UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext();
    
      // Replace the following line with code that emails the image
      UIImageWriteToSavedPhotosAlbum(image1, nil, nil, nil);
      UIGraphicsEndImageContext();
    

    【讨论】:

      【解决方案2】:

      来自http://blogs.zdnet.com/mobile-gadgeteer/?p=1278

      当您在要捕获的屏幕上时,按住主屏幕按钮,然后按电源/睡眠按钮。然后,您的屏幕截图将出现在 iPhone 上的照片库中,您可以根据需要将其发送或同步。

      【讨论】:

      • 没错,我一直在寻找一个编码解决方案。不过,感谢您的回复。
      【解决方案3】:
      猜你喜欢
      • 2010-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-05
      • 1970-01-01
      • 2014-02-08
      相关资源
      最近更新 更多