예제 #1
0
        void ApplyNoirFilter(object sender, EventArgs e)
        {
            Asset.RequestContentEditingInput (new PHContentEditingInputRequestOptions (), (input, options) => {

                // perform the editing operation, which applies a noir filter in this case
                var image = CIImage.FromUrl (input.FullSizeImageUrl);
                image = image.CreateWithOrientation ((CIImageOrientation)input.FullSizeImageOrientation);
                var noir = new CIPhotoEffectNoir {
                    Image = image
                };
                var ciContext = CIContext.FromOptions (null);
                var output = noir.OutputImage;

                var uiImage = UIImage.FromImage (ciContext.CreateCGImage (output, output.Extent));
                imageView.Image = uiImage;

                // save the filtered image data to a PHContentEditingOutput instance
                var editingOutput = new PHContentEditingOutput (input);
                var adjustmentData = new PHAdjustmentData ();
                var data = uiImage.AsJPEG ();
                NSError error;
                data.Save (editingOutput.RenderedContentUrl, false, out error);
                editingOutput.AdjustmentData = adjustmentData;

                // make a change request to publish the changes form the editing output
                PHPhotoLibrary.GetSharedPhotoLibrary.PerformChanges (
                    () => {
                        PHAssetChangeRequest request = PHAssetChangeRequest.ChangeRequest (Asset);
                        request.ContentEditingOutput = editingOutput;
                    },
                    (ok, err) => Console.WriteLine ("photo updated successfully: {0}", ok));
            });
        }
예제 #2
0
        void OnApplyFilter(object sender, EventArgs e)
        {
            Asset.RequestContentEditingInput(new PHContentEditingInputRequestOptions(),
                                             (input, options) => {
                var image = CIImage.FromUrl(input.FullSizeImageUrl);
                image     = image.CreateWithOrientation(input.FullSizeImageOrientation);

                var updatedPhoto = new CIPhotoEffectNoir {
                    Image = image
                };
                var ciContext = CIContext.FromOptions(null);
                var output    = updatedPhoto.OutputImage;

                // Get the upated image
                var uiImage    = UIImage.FromImage(ciContext.CreateCGImage(output, output.Extent));
                TheImage.Image = uiImage;

                // Save the image data to a PHContentEditingOutput instance
                var editingOutput = new PHContentEditingOutput(input);

                NSError error;
                var data = uiImage.AsJPEG();
                data.Save(editingOutput.RenderedContentUrl, false, out error);
                editingOutput.AdjustmentData = new PHAdjustmentData();;

                // Request to publish the changes form the editing output back to the photo library
                PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(
                    () => {
                    PHAssetChangeRequest request = PHAssetChangeRequest.ChangeRequest(Asset);
                    request.ContentEditingOutput = editingOutput;
                },
                    (ok, err) => Console.WriteLine("Photo updated : {0}, {1}", ok, err));
            });
        }
예제 #3
0
        void ApplyNoirFilter(object sender, EventArgs e)
        {
            Asset.RequestContentEditingInput(new PHContentEditingInputRequestOptions(), (input, options) => {
                // perform the editing operation, which applies a noir filter in this case
                var image = CIImage.FromUrl(input.FullSizeImageUrl);
                image     = image.CreateWithOrientation((CIImageOrientation)input.FullSizeImageOrientation);
                var noir  = new CIPhotoEffectNoir {
                    Image = image
                };
                var ciContext = CIContext.FromOptions(null);
                var output    = noir.OutputImage;

                var uiImage     = UIImage.FromImage(ciContext.CreateCGImage(output, output.Extent));
                imageView.Image = uiImage;

                // save the filtered image data to a PHContentEditingOutput instance
                var editingOutput  = new PHContentEditingOutput(input);
                var adjustmentData = new PHAdjustmentData();
                var data           = uiImage.AsJPEG();
                NSError error;
                data.Save(editingOutput.RenderedContentUrl, false, out error);
                editingOutput.AdjustmentData = adjustmentData;

                // make a change request to publish the changes form the editing output
                PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(
                    () => {
                    PHAssetChangeRequest request = PHAssetChangeRequest.ChangeRequest(Asset);
                    request.ContentEditingOutput = editingOutput;
                },
                    (ok, err) => Console.WriteLine("photo updated successfully: {0}", ok));
            });
        }
예제 #4
0
		/// <summary>
		/// Produces a high-contrast black-and-white image.
		/// </summary>
		/// <returns>The altered image.</returns>
		CIImage PhotoEffectNoir ()
		{
			var photo_effect_noir = new CIPhotoEffectNoir ()
			{
				Image = flower
			};

			return photo_effect_noir.OutputImage;
		}