private ImageDimension getImageDim(double imageWidth, double ImageHeight)
        {
            Dictionary<String, double> canvasDim = _getCanvasDim();
              ImageDimension result = null;
              double canvasWidth = canvasDim["Width"];
              double canvasHeight = canvasDim["Height"];
              if (imageWidth > ImageHeight)
              {
            // 水平照片
            double newHeight = canvasWidth * ImageHeight / imageWidth;
            result = new ImageDimension(canvasWidth, newHeight, 0, (canvasHeight - newHeight) / 2, true);
            if (newHeight > canvasHeight)
            {
              double newWidth = canvasHeight * imageWidth / ImageHeight;
              // 这里还是垂直照片
              result = new ImageDimension(newWidth, canvasHeight, (canvasWidth - newWidth) / 2, 0, false);
            }

              }
              else
              {
            // 垂直照片
            double newWidth = canvasHeight * imageWidth / ImageHeight;
            result = new ImageDimension(newWidth, canvasHeight, (canvasWidth - newWidth) / 2, 0, false);
              }
              return result;
        }
 internal void setDisplayImage(BitmapSource bitmapImage)
 {
     double _imageW = bitmapImage.Width;
       double _imageH = bitmapImage.Height;
       theCanvas.Cursor = Cursors.Cross;
       Dictionary<String, double> canvasDim = _getCanvasDim();
       imageDimension = getImageDim(_imageW, _imageH);
       Console.WriteLine(String.Format("Display image {0}X{1}", _imageW, _imageH));
       theImage.Source = bitmapImage;
       theImage.Width = imageDimension.width;
       theImage.Height = imageDimension.height;
       Canvas.SetLeft(theImage, imageDimension.left);
       Canvas.SetTop(theImage, imageDimension.top);
       PrintCatImage.updateImageCtrl(theImage);
 }