|
@@ -79,7 +79,7 @@ class ImageCompareCellView : NSTableCellView {
|
|
|
let lastPathComponent = NSString(string: _fileInfo.refFilePath()!).lastPathComponent
|
|
|
setTitle(String("[\(_fileInfo.objc().fileType()):\(_fileInfo.objc().name())]\(_fileInfo.fileName())/\(lastPathComponent)"))
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
let degree = _fileInfo.degree()
|
|
|
if degree == -1 {
|
|
|
_degreeInfoLbl.stringValue = "文件不存在"
|
|
@@ -146,8 +146,8 @@ class ImageCompareCellView : NSTableCellView {
|
|
|
self._imageView04.image = nil;
|
|
|
_imageView04.isHidden = _showCoverBtn.state == .off || _segmentedControl.indexOfSelectedItem != 1
|
|
|
|
|
|
-// let image2 = NSImage.init(contentsOfFile: resultPath)
|
|
|
-// _imageView04.image = image2;
|
|
|
+ // let image2 = NSImage.init(contentsOfFile: resultPath)
|
|
|
+ // _imageView04.image = image2;
|
|
|
let degree = _fileInfo.degree()
|
|
|
if (abs(degree - 100) > 0) {
|
|
|
_activityView.isHidden = false
|
|
@@ -181,6 +181,72 @@ class ImageCompareCellView : NSTableCellView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func processCompareImage() -> NSImage? {
|
|
|
+ _imageView03.image = nil;
|
|
|
+ _imageView04.image = nil;
|
|
|
+
|
|
|
+ let comparePath = _fileInfo.comparePath()
|
|
|
+ let resultPath = _fileInfo.resultPath()
|
|
|
+
|
|
|
+ let image = NSImage.init(contentsOfFile: comparePath)
|
|
|
+ _imageView01.image = image;
|
|
|
+
|
|
|
+ let image2 = NSImage.init(contentsOfFile: resultPath)
|
|
|
+ _imageView02.image = image2;
|
|
|
+
|
|
|
+ _showCoverBtn.isHidden = true;
|
|
|
+ _segmentedControl.isHidden = true;
|
|
|
+ _degreeInfoLbl.isHidden = true;
|
|
|
+
|
|
|
+ let nimage = self.imageFroView(self)
|
|
|
+ return nimage
|
|
|
+ }
|
|
|
+
|
|
|
+ func processCoverImage() -> NSImage? {
|
|
|
+ let comparePath = _fileInfo.comparePath()
|
|
|
+ let resultPath = _fileInfo.resultPath()
|
|
|
+
|
|
|
+ let image = NSImage.init(contentsOfFile: comparePath)
|
|
|
+ _imageView03.image = image;
|
|
|
+ self._imageView04.image = nil;
|
|
|
+ _imageView04.isHidden = false
|
|
|
+
|
|
|
+ var image2 = nil as NSImage?
|
|
|
+
|
|
|
+ let coverPath = NSString(format: "%@_cover.png", NSString(string: resultPath).deletingPathExtension) as! String
|
|
|
+
|
|
|
+ if FileManager.default.fileExists(atPath: coverPath) {
|
|
|
+ image2 = NSImage.init(contentsOfFile: coverPath)
|
|
|
+ }else {
|
|
|
+ image2 = ImageProcess.processImage(resultPath, checkPath: comparePath)
|
|
|
+
|
|
|
+ if nil != image2 {
|
|
|
+ let rep = NSBitmapImageRep.init(cgImage: image2!.cgImage(forProposedRect: nil, context: nil, hints: nil)!)
|
|
|
+ let data = rep.representation(using: NSBitmapImageRep.FileType.png, properties: [:]);
|
|
|
+
|
|
|
+ let url = URL.init(fileURLWithPath: coverPath, isDirectory: false)
|
|
|
+ try? data!.write(to: url)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ self._imageView04.image = image2
|
|
|
+ self._activityView.isHidden = true
|
|
|
+
|
|
|
+ self._showCoverBtn.isHidden = true;
|
|
|
+ self._segmentedControl.isHidden = true;
|
|
|
+ self._degreeInfoLbl.isHidden = true;
|
|
|
+
|
|
|
+ let nimage = self.imageFroView(self)
|
|
|
+ return nimage
|
|
|
+ }
|
|
|
+
|
|
|
+ func imageFroView(_ view:NSView) -> NSImage? {
|
|
|
+ let data = view.dataWithPDF(inside: view.frame)
|
|
|
+ let image = NSImage.init(data: data);
|
|
|
+
|
|
|
+ return image ?? nil;
|
|
|
+ }
|
|
|
+
|
|
|
@IBAction func showCoverAction(_ sender:NSButton) {
|
|
|
if sender.state == .on {
|
|
|
_showCoverBtn.title = "隐藏覆盖层"
|