【发布时间】:2016-12-02 23:52:22
【问题描述】:
我只是从 swift 和 cocoa 开始。我正在尝试创建一个进行图像处理的基本应用程序。
我已经有了这张图片的所有信息:
let imageRef:CGImageSourceRef = CGImageSourceCreateWithURL(url, nil).takeUnretainedValue()
let imageDict:CFDictionaryRef = CGImageSourceCopyPropertiesAtIndex(imageRef, 0, nil).takeUnretainedValue()
字典包含以下信息:
{
ColorModel = Gray;
DPIHeight = 300;
DPIWidth = 300;
Depth = 1;
Orientation = 1;
PixelHeight = 4167;
PixelWidth = 4167;
"{Exif}" = {
ColorSpace = 65535;
DateTimeDigitized = "2014:07:09 20:25:49";
PixelXDimension = 4167;
PixelYDimension = 4167;
};
"{TIFF}" = {
Compression = 1;
DateTime = "2014:07:09 20:25:49";
Orientation = 1;
PhotometricInterpretation = 0;
ResolutionUnit = 2;
Software = "Adobe Photoshop CS6 (Macintosh)";
XResolution = 300;
YResolution = 300;
};
}
现在我想使用以下代码读取 DPI 的值,但“__conversion”存在一些问题,我不明白。
let dpiH:NSNumber = CFDictionaryGetValue(imageDict, kCGImagePropertyDPIWidth)
我做错了什么,如何获得字典的所需值?
【问题讨论】:
-
你能发布你在 xCode 中收到的整个错误吗?
-
它停止编译并出现该错误:“无法为接受提供的参数的 '__conversion' 找到重载”
-
上面的错误信息不是副本:“fing”。
-
对不起,错字。应该是“找到”。手动输入,但如果您喜欢导航器中的副本:
Could not find an overload for '__conversion' that accepts the supplied arguments
标签: macos swift core-graphics key-value core-foundation