<small id='MDvNC'></small><noframes id='MDvNC'>

  • <i id='MDvNC'><tr id='MDvNC'><dt id='MDvNC'><q id='MDvNC'><span id='MDvNC'><b id='MDvNC'><form id='MDvNC'><ins id='MDvNC'></ins><ul id='MDvNC'></ul><sub id='MDvNC'></sub></form><legend id='MDvNC'></legend><bdo id='MDvNC'><pre id='MDvNC'><center id='MDvNC'></center></pre></bdo></b><th id='MDvNC'></th></span></q></dt></tr></i><div id='MDvNC'><tfoot id='MDvNC'></tfoot><dl id='MDvNC'><fieldset id='MDvNC'></fieldset></dl></div>
        <bdo id='MDvNC'></bdo><ul id='MDvNC'></ul>

      1. <tfoot id='MDvNC'></tfoot>
        <legend id='MDvNC'><style id='MDvNC'><dir id='MDvNC'><q id='MDvNC'></q></dir></style></legend>

      2. 将图像旋转 3*Double.pi/2 使图像不出现(swift3)

        时间:2023-05-18
            <tbody id='O5CTK'></tbody>

          1. <tfoot id='O5CTK'></tfoot>
            <i id='O5CTK'><tr id='O5CTK'><dt id='O5CTK'><q id='O5CTK'><span id='O5CTK'><b id='O5CTK'><form id='O5CTK'><ins id='O5CTK'></ins><ul id='O5CTK'></ul><sub id='O5CTK'></sub></form><legend id='O5CTK'></legend><bdo id='O5CTK'><pre id='O5CTK'><center id='O5CTK'></center></pre></bdo></b><th id='O5CTK'></th></span></q></dt></tr></i><div id='O5CTK'><tfoot id='O5CTK'></tfoot><dl id='O5CTK'><fieldset id='O5CTK'></fieldset></dl></div>

            1. <legend id='O5CTK'><style id='O5CTK'><dir id='O5CTK'><q id='O5CTK'></q></dir></style></legend>
                  <bdo id='O5CTK'></bdo><ul id='O5CTK'></ul>

                  <small id='O5CTK'></small><noframes id='O5CTK'>

                • 本文介绍了将图像旋转 3*Double.pi/2 使图像不出现(swift3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  尝试将我的图像方向旋转 270 度我可以旋转 90 度并且图像出现但是当将图像旋转 270 时没有任何反应.我添加了 2 张 90 度和 270 度命令的图片,以使事情更清楚.

                  Trying to rotate my image orientation by 270 degrees I can rotate by 90 degrees and the image appears however when rotating the image by 270 nothing happens. I have added 2 pictures of the 90 and 270 degrees commands to make things more clear.

                  extension CIImage {
                  var image: UIImage? { return UIImage(ciImage: self) }
                  var rotatingLeft: CIImage? {
                      let transform = CGAffineTransform(translationX: extent.midX, y: extent.midY)
                          .rotated(by: CGFloat.pi.divided(by: 2))
                          .translatedBy(x: -extent.midX, y: -extent.midY)
                      return CIFilter(name: "CIAffineTransform", withInputParameters: [kCIInputImageKey: self, kCIInputTransformKey: NSValue(cgAffineTransform: transform)])?.outputImage
                  }
                  var rotatingRight: CIImage? {
                      let transform = CGAffineTransform(translationX: extent.midX, y: extent.midY)
                          .rotated(by: -CGFloat.pi.divided(by: 2))
                          .translatedBy(x: -extent.midX, y: -extent.midY)
                      return CIFilter(name: "CIAffineTransform", withInputParameters: [kCIInputImageKey: self, kCIInputTransformKey: NSValue(cgAffineTransform: transform)])?.outputImage
                  }
                  }
                  
                  extension UIImage {
                  var ciimage: CIImage? { return CIImage(image: self) }
                  }
                  
                  
                  
                  
                  
                  import UIKit
                  
                  class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate   {
                  @IBOutlet var displayImage: UIImageView!
                  
                  
                  var currentImageView: UIImageView?
                  
                  func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
                      let image = info[UIImagePickerControllerOriginalImage] as! UIImage
                      self.currentImageView?.image = displayImage.image
                  
                      self.currentImageView?.image = image.ciimage?.rotatingLeft?.image
                  
                      self.dismiss(animated: true)
                  
                  
                  }
                  
                      func image(_ image: UIImage, didFinishSavingWithError error: NSError?, contextInfo: UnsafeRawPointer) {
                          if let error = error {
                              // we got back an error!
                              let ac = UIAlertController(title: "Save error", message: error.localizedDescription, preferredStyle: .alert)
                              ac.addAction(UIAlertAction(title: "OK", style: .default))
                              present(ac, animated: true)
                          } else {
                  
                              let ac = UIAlertController(title: "Image Saved!", message: "Your image has been saved to your photos.", preferredStyle: .alert)
                              ac.addAction(UIAlertAction(title: "OK", style: .default))
                              present(ac, animated: true)
                          }
                      }
                  
                  @IBAction func takePhoto(_ sender: Any) {
                  
                  
                  
                      self.currentImageView = self.displayImage
                  
                  
                  
                      let imagePicker = UIImagePickerController()
                      imagePicker.delegate = self
                  
                  
                      imagePicker.sourceType = UIImagePickerControllerSourceType.camera;
                      imagePicker.allowsEditing = false
                      self.present(imagePicker, animated: true, completion: nil)
                  
                  }}
                  

                  推荐答案

                  您可以扩展 CIImage 而不是 UIImage,并使用转换矩阵使用核心图像过滤器 CIAffineTransform.开始将其平移到中心,将其旋转 90 度 (.pi/2) 并将其移回:

                  You can extend CIImage instead of UIImage and use core image filter CIAffineTransform using the transformation matrix. Start translating it to the center, rotate it 90 degrees (.pi/2) and move it back:

                  extension CIImage {
                      var image: UIImage? { return UIImage(ciImage: self) }
                      func rotated(_ angle: CGFloat) -> CIImage? {
                          let transform = CGAffineTransform(translationX: extent.midX, y: extent.midY)
                              .rotated(by: angle * .pi /  180)
                              .translatedBy(x: -extent.midX, y: -extent.midY)
                          return CIFilter(name: "CIAffineTransform", withInputParameters: [kCIInputImageKey: self, kCIInputTransformKey: NSValue(cgAffineTransform: transform)])?.outputImage
                      }
                      var rotatedLeft: CIImage? { return rotated(90) }
                      var rotatedRight: CIImage? { return rotated(-90) }
                  }
                  

                  <小时>

                  游乐场测试:


                  Playground testing:

                  let image = UIImage(data: try! Data(contentsOf: URL(string:"https://i.stack.imgur.com/Xs4RX.jpg")!))!
                  image.ciimage?.rotated(22.5)?.image
                  image.ciimage?.rotatedRight?.image
                  image.ciimage?.rotatedLeft?.image
                  

                  这篇关于将图像旋转 3*Double.pi/2 使图像不出现(swift3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何处理UIViewController的旋转,该rotoiewontroller在uinavigationContro 下一篇:在 Android 中使用 Canvas.DrawBitmap 进行 Sprite 旋转.我很接近,我做错了什么?

                  相关文章

                • <i id='0PwyQ'><tr id='0PwyQ'><dt id='0PwyQ'><q id='0PwyQ'><span id='0PwyQ'><b id='0PwyQ'><form id='0PwyQ'><ins id='0PwyQ'></ins><ul id='0PwyQ'></ul><sub id='0PwyQ'></sub></form><legend id='0PwyQ'></legend><bdo id='0PwyQ'><pre id='0PwyQ'><center id='0PwyQ'></center></pre></bdo></b><th id='0PwyQ'></th></span></q></dt></tr></i><div id='0PwyQ'><tfoot id='0PwyQ'></tfoot><dl id='0PwyQ'><fieldset id='0PwyQ'></fieldset></dl></div>
                  <tfoot id='0PwyQ'></tfoot>
                  1. <small id='0PwyQ'></small><noframes id='0PwyQ'>

                      <bdo id='0PwyQ'></bdo><ul id='0PwyQ'></ul>

                    <legend id='0PwyQ'><style id='0PwyQ'><dir id='0PwyQ'><q id='0PwyQ'></q></dir></style></legend>