【问题标题】:Create CIImage with same image scale?创建具有相同图像比例的 CIImage?
【发布时间】:2016-12-13 11:34:10
【问题描述】:

我有这样的对象的 UIImage

<UIImage: 0x17428b540> size {937.5, 1250} orientation 0 scale 2.000000

我想创建 CIIImage。

CIImage* ciImage = [[CIImage alloc] initWithCGImage:image.CGImage options:nil];

它的输出是这样的:

<CIImage: 0x174c003b0 extent [0 0 1875 2500]>

您可以看到 CIImage 的大小是 UIImage 大小的两倍。如何获得与 UIImage 相同比例(大小)的 CIImage?

【问题讨论】:

  • CIImage 正在获取该图像的点而不是像素,因此它是该图像的打印点。我认为....
  • 你解决了吗?

标签: ios objective-c uiimage


【解决方案1】:

CIImageCGImage 没有比例。只有当您将它们转换为 UIImage 时,您才能设置比例。

例如,要从 CGImage 创建带有刻度的 UIImage,请使用:

let image = UIImage(cgImage: your_cgImage, scale: your_scale, orientation: your_orientation)

(斯威夫特 4)

【讨论】:

    【解决方案2】:

    你可以试试这个

    UIImage *image = YOUR_IMAGE;
    CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
    CGImageRef imgRef = CGImageCreateWithImageInRect([image CGImage], rect); // It returns CIImage only and size will be same.
    

    【讨论】:

      猜你喜欢
      • 2016-05-05
      • 1970-01-01
      • 2011-06-28
      • 2020-06-24
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-29
      相关资源
      最近更新 更多