Example #1
0
        unsafe void BrowseButton_Activated(object sender, EventArgs e)
        {
            NSOpenPanel panel = new NSOpenPanel();

            panel.CanChooseFiles          = true;
            panel.CanChooseDirectories    = false;
            panel.AllowsMultipleSelection = true;
            panel.CanCreateDirectories    = true;

            using (panel)
            {
                nint result = panel.RunModal();
                if (result != 1)
                {
                    return;
                }

                NSUrl[] urls = panel.Urls;
                if (urls.Length == 0)
                {
                    return;
                }

                NSUrl leftImagePath  = urls[1];
                NSUrl rightImagePath = urls[0];

                mLeftImage  = new NSImage(leftImagePath.Path, false);
                mRightImage = new NSImage(rightImagePath.Path, false);

                NSBitmapImageRep leftImageRep =
                    ImageDiffUtils.GetBitmapRepresentation(mLeftImage);

                NSBitmapImageRep rightImageRep =
                    ImageDiffUtils.GetBitmapRepresentation(mRightImage);

                nint leftLen  = leftImageRep.BytesPerRow * leftImageRep.PixelsHigh;
                nint rightLen = rightImageRep.BytesPerRow * rightImageRep.PixelsHigh;

                byte *leftBitmapData  = (byte *)leftImageRep.BitmapData;
                byte *rightBitmapData = (byte *)rightImageRep.BitmapData;

                ImageDiffOperations.CalculateImageDiff(
                    this, this, leftBitmapData, rightBitmapData,
                    (int)leftLen, (int)rightLen);
            }
        }
Example #2
0
 void IImageDiffView.SetDiffImageBytes(byte[] diffImage)
 {
     mImageDiffView.SetImage(
         ImageDiffUtils.GetDiffImage(mLeftImage, mRightImage, diffImage));
 }