         super.viewDidLoad()
         trimmedImage = image
         segment.selectedSegmentIndex = 0
+        viewMain.addSubview(borderView)
         updateUI()
     }
     

        // Dispose of any resources that can be recreated.
    }
    
    private func setTransformAnimated(xform:CGAffineTransform) {
        self.xform = xform
        UIView.animateWithDuration(0.2) { 
            self.viewMain.transform = xform
        }
    }

    @IBAction func done() {

            }
        case .Ended:
            xform = self.viewMain.transform
            let frame = boundCheck()
            self.borderView.frame = CGRectApplyAffineTransform(frame, CGAffineTransformInvert(self.imageTransform))
            self.borderView.alpha = 1.0
            UIView.animateWithDuration(0.5, animations: {
                self.borderView.alpha = 0.0
            })
        default:
            self.viewMain.transform = xform
        }
    }
    
    func boundCheck() -> CGRect {
        let size = trimmedImage.size
        let data = NSMutableData(length: 4 * Int(size.width) * Int(size.height))!
        //let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue)
