/// <summary> /// Initializes a new instance of the <see cref="OSXSurfaceSource"/> class from the specified image. /// </summary> /// <param name="stream">The <see cref="NSImage"/> that contains the surface data.</param> public OSXSurfaceSource(NSImage image) { Contract.Require(image, "image"); this.image = image; this.imageRep = new NSBitmapImageRep(image.CGImage); }
private void CreateAbout () { this.about_image = NSImage.ImageNamed ("about"); this.about_image.Size = new SizeF (720, 260); this.about_image_view = new NSImageView () { Image = this.about_image, Frame = new RectangleF (0, 0, 720, 260) }; this.version_text_field = new SparkleLabel ("version " + Controller.RunningVersion, NSTextAlignment.Left) { DrawsBackground = false, Frame = new RectangleF (295, 140, 318, 22), TextColor = NSColor.White }; this.updates_text_field = new SparkleLabel ("Checking for updates...", NSTextAlignment.Left) { DrawsBackground = false, Frame = new RectangleF (295, Frame.Height - 232, 318, 98), TextColor = NSColor.FromCalibratedRgba (1.0f, 1.0f, 1.0f, 0.5f) }; this.credits_text_field = new SparkleLabel ( @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others." + "\n\n" + "SparkleShare is Open Source. You are free to use, modify, and redistribute it " + "under the GNU GPLv3.", NSTextAlignment.Left) { DrawsBackground = false, Frame = new RectangleF (295, Frame.Height - 260, 318, 98), TextColor = NSColor.White }; this.website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress); this.website_link.Frame = new RectangleF (new PointF (295, 25), this.website_link.Frame.Size); this.credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress); this.credits_link.Frame = new RectangleF ( new PointF (this.website_link.Frame.X + this.website_link.Frame.Width + 10, 25), this.credits_link.Frame.Size); this.report_problem_link = new SparkleLink ("Report a problem", Controller.ReportProblemLinkAddress); this.report_problem_link.Frame = new RectangleF ( new PointF (this.credits_link.Frame.X + this.credits_link.Frame.Width + 10, 25), this.report_problem_link.Frame.Size); this.debug_log_link = new SparkleLink ("Debug log", Controller.DebugLogLinkAddress); this.debug_log_link.Frame = new RectangleF ( new PointF (this.report_problem_link.Frame.X + this.report_problem_link.Frame.Width + 10, 25), this.debug_log_link.Frame.Size); ContentView.AddSubview (this.about_image_view); ContentView.AddSubview (this.version_text_field); ContentView.AddSubview (this.updates_text_field); ContentView.AddSubview (this.credits_text_field); ContentView.AddSubview (this.website_link); ContentView.AddSubview (this.credits_link); ContentView.AddSubview (this.report_problem_link); ContentView.AddSubview (this.debug_log_link); }
public IBasicImage CreateImageFromByteArray(byte[] data, int width, int height) { IBasicImage image = null; NSImage imageResized = null; try { //Console.WriteLine("DisposableImageFactory - CreateImageFromByteArray - width: {0} height: {1}", width, height); NSGraphicsContext.GlobalRestoreGraphicsState(); using (NSData imageData = NSData.FromArray(data)) { InvokeOnMainThread(() => { using (NSImage imageFullSize = new NSImage(imageData)) { try { imageResized = CoreGraphicsHelper.ScaleImageSquare(imageFullSize, width); } catch (Exception ex) { Console.WriteLine("DisposableImageFactory - Error resizing image: {0}", ex); } } }); } image = new BasicImage(imageResized); return image; } catch (Exception ex) { Console.WriteLine("DisposableImageFactory - Failed to process image: {0}", ex); } return image; }
public SetupWindow() { SetFrame (new RectangleF (0, 0, 640, 420), true); StyleMask = NSWindowStyle.Titled; MaxSize = new SizeF (640, 420); MinSize = new SizeF (640, 420); HasShadow = true; IsOpaque = false; BackingType = NSBackingStore.Buffered; Level = NSWindowLevel.Floating; Center (); this.side_splash = NSImage.ImageNamed ("side-splash"); this.side_splash.Size = new SizeF (150, 482); this.side_splash_view = new NSImageView () { Image = this.side_splash, Frame = new RectangleF (0, 0, 150, 482) }; this.header_text_field = new SparkleLabel ("", NSTextAlignment.Left) { Frame = new RectangleF (190, Frame.Height - 80, Frame.Width, 24), Font = NSFontManager.SharedFontManager.FontWithFamily ( UserInterface.FontName, NSFontTraitMask.Bold, 0, 16) }; this.description_text_field = new SparkleLabel ("", NSTextAlignment.Left) { Frame = new RectangleF (190, Frame.Height - 130, 640 - 240, 44) }; this.header_text_field.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; }
public void Create() { // load reign image string path = NSBundle.MainBundle.PathForResource("Images/Logo", "png", "", "Images/"); var image = new NSImage(path); imageView.Image = image; // set UI values InjectorCore.FindUnityPath(); InjectorCore.LoadPaths(); unityPath.StringValue = checkNull(InjectorCore.UnityPath); barFileName.StringValue = checkNull(InjectorCore.BarFileName); scoreloopPath.StringValue = checkNull(InjectorCore.ScoreloopBundlePath); keyName.StringValue = checkNull(InjectorCore.KeyPassword); signBarFile.State = InjectorCore.SignBarFile ? NSCellStateValue.On : NSCellStateValue.Off; phoneIP.StringValue = checkNull(InjectorCore.PhoneIP); phoneLockPass.StringValue = checkNull(InjectorCore.PhonePass); unityClassicMode.Activated += unityClassicMode_Click; unityPath.Changed += unityPath_Changed; barFileName.Changed += barFileName_Changed; scoreloopPath.Changed += scoreloopPath_Changed; keyName.Changed += keyName_Changed; phoneIP.Changed += phoneIP_Changed; phoneLockPass.Changed += phoneLockPass_Changed; // get button events applyButton.Activated += applyButton_Click; selectBarFile.Activated += selectBarFile_Click; selectScoreloopData.Activated += selectScoreloopData_Click; signBarFile.Activated += signBarFile_Click; uploadButton.Activated += uploadButton_Click; }
public void SetBackgroundImage(NSImage image) { BackgroundImage.Image = image; BackgroundImage.SetFrameSize (image.Size); BackgroundImage.SetFrameOrigin (new PointF ( (Frame.Width - image.Size.Width) / 2, (Frame.Height - image.Size.Height) / 2)); BackgroundImage.AutoresizingMask = NSViewResizingMask.MinXMargin | NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin | NSViewResizingMask.MaxYMargin; }
public override object CreateMultiResolutionImage (IEnumerable<object> images) { NSImage res = new NSImage (); foreach (NSImage img in images) res.AddRepresentations (img.Representations ()); return res; }
public SparkleWindow() : base() { SetFrame (new RectangleF (0, 0, 640, 480), true); Center (); StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Miniaturizable | NSWindowStyle.Titled); MaxSize = new SizeF (640, 480); MinSize = new SizeF (640, 480); HasShadow = true; BackingType = NSBackingStore.Buffered; SideSplash = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/side-splash.png"); SideSplash.Size = new SizeF (150, 480); NSText tv = new NSText (new RectangleF (200, 200, 200, 200)) { Value = "TEST" }; ContentView.AddSubview (new NSImageView (new RectangleF (0, 0, 150, 480)) { Image = SideSplash}); ContentView.AddSubview (new NSTextField (new RectangleF (200, 100, 128, 31)) { BezelStyle = NSTextFieldBezelStyle.Rounded}); ContentView.AddSubview (tv); NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); MakeKeyAndOrderFront (this); }
void GetImagaDataFromPath (string path) { NSImage src; CGImage image; CGContext context = null; src = new NSImage (path); var rect = RectangleF.Empty; image = src.AsCGImage (ref rect, null, null); width = image.Width; height = image.Height; data = new byte[width * height * 4]; CGImageAlphaInfo ai = CGImageAlphaInfo.PremultipliedLast; context = new CGBitmapContext (data, width, height, 8, 4 * width, image.ColorSpace, ai); // Core Graphics referential is upside-down compared to OpenGL referential // Flip the Core Graphics context here // An alternative is to use flipped OpenGL texture coordinates when drawing textures context.TranslateCTM (0, height); context.ScaleCTM (1, -1); // Set the blend mode to copy before drawing since the previous contents of memory aren't used. // This avoids unnecessary blending. context.SetBlendMode (CGBlendMode.Copy); context.DrawImage (new RectangleF (0, 0, width, height), image); }
public void DrawThreePartImage (RectangleF frame, NSImage startCap, NSImage centerFill, NSImage endCap, bool vertical, NSCompositingOperation op, float alphaFraction, bool flipped) { NSDrawThreePartImage ( frame, startCap != null ? startCap.Handle : IntPtr.Zero, centerFill != null ? centerFill.Handle : IntPtr.Zero, endCap != null ? endCap.Handle : IntPtr.Zero, vertical, (int)op, alphaFraction, flipped); }
public static NSImage ToNSImage(this CIImage image, System.Drawing.SizeF size) { var imageRep = NSCIImageRep.FromCIImage(image); var nsImage = new NSImage(size); nsImage.AddRepresentation(imageRep); return nsImage; }
public static IBitmap FromNative(this UIImage This, bool copy = false) { if (copy) { return(new CocoaBitmap((UIImage)This.Copy())); } return(new CocoaBitmap(This)); }
public override object CreateImage (object backend) { var gc = (CGContextBackend)backend; var img = new NSImage (((CGBitmapContext)gc.Context).ToImage (), gc.Size); var imageData = img.AsTiff (); var imageRep = (NSBitmapImageRep) NSBitmapImageRep.ImageRepFromData (imageData); var im = new NSImage (); im.AddRepresentation (imageRep); return im; }
public IBasicImage RenderToImageInMemory() { NSImage image = null; InvokeOnMainThread(() => { //Console.WriteLine("MemoryGraphicsContextWrapper - RenderToImageInMemory"); NSGraphicsContext.GlobalRestoreGraphicsState(); image = new NSImage(new SizeF(BoundsWidth, BoundsHeight)); image.AddRepresentation(_bitmap); }); var basicImage = new BasicImage(image); return basicImage; }
public SparkleSetupWindow() : base() { SetFrame (new RectangleF (0, 0, 640, 420), true); StyleMask = NSWindowStyle.Titled; MaxSize = new SizeF (640, 420); MinSize = new SizeF (640, 420); HasShadow = true; BackingType = NSBackingStore.Buffered; Center (); string side_splash_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "side-splash.png"); SideSplash = new NSImage (side_splash_path) { Size = new SizeF (150, 482) }; SideSplashView = new NSImageView () { Image = SideSplash, Frame = new RectangleF (0, 0, 150, 482) }; Buttons = new List <NSButton> (); HeaderTextField = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 100, Frame.Width, 48), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Bold, 0, 15) }; DescriptionTextField = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 130, 640 - 240, 44), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = SparkleUI.Font }; NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); MakeKeyAndOrderFront (this); OrderFrontRegardless (); if (Program.UI != null) Program.UI.UpdateDockIconVisibility (); }
public static NSImage Tint(this NSImage image, NSColor tint) { var colorGenerator = new CIConstantColorGenerator { Color = CIColor.FromCGColor(tint.CGColor) }; var colorFilter = new CIColorControls { Image = (CIImage)colorGenerator.ValueForKey(CIFilterOutputKey.Image), Saturation = 3f, Brightness = 0.35f, Contrast = 1f }; var monochromeFilter = new CIColorMonochrome { Image = CIImage.FromCGImage(image.CGImage), Color = CIColor.FromRgb(0.75f, 0.75f, 0.75f), Intensity = 1f }; var compositingFilter = new CIMultiplyCompositing { Image = (CIImage)colorFilter.ValueForKey(CIFilterOutputKey.Image), BackgroundImage = (CIImage)monochromeFilter.ValueForKey(CIFilterOutputKey.Image) }; var outputImage = (CIImage)compositingFilter.ValueForKey(CIFilterOutputKey.Image); var extent = outputImage.Extent; var newsize = sd.Size.Truncate(extent.Size); if (newsize.IsEmpty) return image; var tintedImage = new NSImage(newsize); tintedImage.LockFocus(); try { var graphics = NSGraphicsContext.CurrentContext.GraphicsPort; var ciContext = CIContext.FromContext(graphics, new CIContextOptions { UseSoftwareRenderer = true }); ciContext.DrawImage(outputImage, extent, extent); } finally { tintedImage.UnlockFocus(); } var newrep = tintedImage.Representations()[0]; newrep.Size = image.Size; return tintedImage; }
public void DrawNinePartImage (RectangleF frame, NSImage topLeftCorner, NSImage topEdgeFill, NSImage topRightCorner, NSImage leftEdgeFill, NSImage centerFill, NSImage rightEdgeFill, NSImage bottomLeftCorner, NSImage bottomEdgeFill, NSImage bottomRightCorner, NSCompositingOperation op, float alphaFraction, bool flipped) { NSDrawNinePartImage ( frame, topLeftCorner != null ? topLeftCorner.Handle : IntPtr.Zero, topEdgeFill != null ? topEdgeFill.Handle : IntPtr.Zero, topRightCorner != null ? topRightCorner.Handle : IntPtr.Zero, leftEdgeFill != null ? leftEdgeFill.Handle : IntPtr.Zero, centerFill != null ? centerFill.Handle : IntPtr.Zero, rightEdgeFill != null ? rightEdgeFill.Handle : IntPtr.Zero, bottomLeftCorner != null ? bottomLeftCorner.Handle : IntPtr.Zero, bottomEdgeFill != null ? bottomEdgeFill.Handle : IntPtr.Zero, bottomRightCorner != null ? bottomRightCorner.Handle : IntPtr.Zero, (int)op, alphaFraction, flipped); }
public static NSImage Resize(this NSImage image, sd.Size newsize, ImageInterpolation interpolation = ImageInterpolation.Default) { var newimage = new NSImage(newsize); var newrep = new NSBitmapImageRep(IntPtr.Zero, newsize.Width, newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * newsize.Width, 32); newimage.AddRepresentation(newrep); var graphics = NSGraphicsContext.FromBitmap(newrep); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext = graphics; graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG(); image.DrawInRect(new sd.RectangleF(sd.PointF.Empty, newimage.Size), new sd.RectangleF(sd.PointF.Empty, image.Size), NSCompositingOperation.SourceOver, 1f); NSGraphicsContext.GlobalRestoreGraphicsState(); return newimage; }
public SparkleStatusIcon () { this.status_item.HighlightMode = true; this.status_item.Image = this.syncing_idle_image; this.status_item.Image.Template = true; if (Environment.OSVersion.Version.Major >= 14) this.sparkleshare_image = (NSImage)NSImage.ImageNamed ("sparkleshare-folder-yosemite.icns").Copy(); else this.sparkleshare_image = (NSImage)NSImage.ImageNamed ("sparkleshare-folder.icns").Copy(); CreateMenu (); Controller.UpdateIconEvent += delegate (IconState state) { Program.Controller.Invoke (() => { switch (state) { case IconState.Idle: { this.status_item.Image = this.syncing_idle_image; break; } case IconState.SyncingUp: { this.status_item.Image = this.syncing_up_image; break; } case IconState.SyncingDown: { this.status_item.Image = this.syncing_down_image; break; } case IconState.Syncing: { this.status_item.Image = this.syncing_image; break; } case IconState.Error: { this.status_item.Image = this.syncing_error_image; break; } } this.status_item.Image.Template = true; }); }; Controller.UpdateStatusItemEvent += delegate (string state_text) { Program.Controller.Invoke (() => { this.state_item.Title = state_text; if (Controller.Projects.Length == this.state_menu_items.Length) { for (int i = 0; i < Controller.Projects.Length; i++) this.state_menu_items [i].Title = Controller.Projects [i].StatusMessage; } }); }; Controller.UpdateMenuEvent += delegate { while (this.menu_delegate.MenuIsOpen) System.Threading.Thread.Sleep (100); Program.Controller.Invoke (() => CreateMenu ()); }; Controller.UpdateQuitItemEvent += delegate (bool quit_item_enabled) { Program.Controller.Invoke (() => { this.quit_item.Enabled = quit_item_enabled; }); }; }
/// <summary> /// Generates the image. /// </summary> /// <returns>The image.</returns> /// <param name="view">View.</param> public static NSImage GenerateImage(this NSView view) { RectangleF bounds = view.Bounds; NSBitmapImageRep bir = view.BitmapImageRepForCachingDisplayInRect (bounds); bir.Size = bounds.Size; view.CacheDisplay (bounds, bir); NSImage targetImage = new NSImage(bounds.Size); targetImage.LockFocus(); bir.DrawInRect(bounds); targetImage.UnlockFocus(); return targetImage; }
void MediaChooser (object sender, EventArgs e) { var openPanel = new NSOpenPanel(); openPanel.ReleasedWhenClosed = true; openPanel.Prompt = "Select file"; var result = openPanel.RunModal(); if (result == 1) { NSImage image = new NSImage (openPanel.Url); imageView.Image = image; } }
public SparkleSetupWindow() : base() { SetFrame (new RectangleF (0, 0, 640, 420), true); StyleMask = NSWindowStyle.Titled; MaxSize = new SizeF (640, 420); MinSize = new SizeF (640, 420); HasShadow = true; BackingType = NSBackingStore.Buffered; Center (); string side_splash_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "side-splash.png"); this.side_splash = new NSImage (side_splash_path) { Size = new SizeF (150, 482) }; this.side_splash_view = new NSImageView () { Image = this.side_splash, Frame = new RectangleF (0, 0, 150, 482) }; this.header_text_field = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 80, Frame.Width, 24), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ( "Lucida Grande", NSFontTraitMask.Bold, 0, 15), }; this.header_text_field.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; this.description_text_field = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 130, 640 - 240, 44), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ( "Lucida Grande", NSFontTraitMask.Condensed, 0, 13) }; if (Program.UI != null) Program.UI.UpdateDockIconVisibility (); }
public static void Colourize(NSView control, Color color, Action drawAction) { var size = control.Frame.Size; if (size.Width <= 0 || size.Height <= 0) return; var image = new NSImage(size); image.LockFocusFlipped(control.IsFlipped); drawAction(); image.UnlockFocus(); var ciImage = CIImage.FromCGImage(image.CGImage); SD.SizeF realSize; if (control.RespondsToSelector(selConvertSizeToBacking)) realSize = control.ConvertSizeToBacking(size); else realSize = control.ConvertSizeToBase(size); if (control.IsFlipped) { var affineTransform = new NSAffineTransform(); affineTransform.Translate(0, realSize.Height); affineTransform.Scale(1, -1); var filter1 = new CIAffineTransform(); filter1.Image = ciImage; filter1.SetValueForKey(affineTransform, CIInputTransform); ciImage = filter1.ValueForKey(CIOutputImage) as CIImage; } var filter2 = new CIColorControls(); filter2.SetDefaults(); filter2.Image = ciImage; filter2.Saturation = 0.0f; ciImage = filter2.ValueForKey(CIOutputImage) as CIImage; var filter3 = new CIColorMatrix(); filter3.SetDefaults(); filter3.Image = ciImage; filter3.RVector = new CIVector(0, color.R, 0); filter3.GVector = new CIVector(color.G, 0, 0); filter3.BVector = new CIVector(0, 0, color.B); ciImage = filter3.ValueForKey(CIOutputImage) as CIImage; ciImage.Draw(new SD.RectangleF(SD.PointF.Empty, size), new SD.RectangleF(SD.PointF.Empty, realSize), NSCompositingOperation.SourceOver, 1); }
public static NSImage Tint(this NSImage image, NSColor tint) { CIFilter colorGenerator = CIFilter.FromName("CIConstantColorGenerator"); CIColor color = CIColor.FromCGColor(tint.ToCG()); colorGenerator.SetValueForKey(color, CIFilterInputKey.Color); CIFilter colorFilter = CIFilter.FromName("CIColorControls"); colorFilter.SetValueForKey(colorGenerator.ValueForKey(CIFilterOutputKey.Image), CIFilterInputKey.Image); colorFilter.SetValueForKey(NSNumber.FromFloat(3f), CIFilterInputKey.Saturation); colorFilter.SetValueForKey(NSNumber.FromFloat(0.35f), CIFilterInputKey.Brightness); colorFilter.SetValueForKey(NSNumber.FromFloat(1f), CIFilterInputKey.Contrast); CIFilter monochromeFilter = CIFilter.FromName("CIColorMonochrome"); CIImage baseImage = CIImage.FromCGImage(image.CGImage); monochromeFilter.SetValueForKey(baseImage, CIFilterInputKey.Image); monochromeFilter.SetValueForKey(CIColor.FromRgb(0.75f, 0.75f, 0.75f), CIFilterInputKey.Color); monochromeFilter.SetValueForKey(NSNumber.FromFloat(1f), CIFilterInputKey.Intensity); CIFilter compositingFilter = CIFilter.FromName("CIMultiplyCompositing"); compositingFilter.SetValueForKey(colorFilter.ValueForKey(CIFilterOutputKey.Image), CIFilterInputKey.Image); compositingFilter.SetValueForKey(monochromeFilter.ValueForKey(CIFilterOutputKey.Image), CIFilterInputKey.BackgroundImage); CIImage outputImage = (CIImage)compositingFilter.ValueForKey(CIFilterOutputKey.Image); var extent = outputImage.Extent; var newsize = sd.Size.Truncate(extent.Size); var tintedImage = new NSImage(newsize); var newrep = new NSBitmapImageRep(IntPtr.Zero, newsize.Width, newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * newsize.Width, 32); tintedImage.AddRepresentation(newrep); var graphics = NSGraphicsContext.FromBitmap(newrep); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext = graphics; var ciContext = CIContext.FromContext(graphics.GraphicsPort, new CIContextOptions { UseSoftwareRenderer = true }); ciContext.DrawImage(outputImage, extent, extent); NSGraphicsContext.GlobalRestoreGraphicsState(); newrep.Size = image.Size; return tintedImage; }
public Task <IBitmap> LoadFromResource(string source, float?desiredWidth, float?desiredHeight) { var tcs = new TaskCompletionSource <IBitmap>(); UIApplication.SharedApplication.InvokeOnMainThread(() => { try { #if UIKIT tcs.TrySetResult(new CocoaBitmap(UIImage.FromBundle(source))); #else tcs.TrySetResult(new CocoaBitmap(UIImage.ImageNamed(source))); #endif } catch (Exception ex) { tcs.TrySetException(ex); } }); return(tcs.Task); }
public static void Colourize (NSView control, Color color, Action drawAction) { var size = control.Frame.Size; var image = new NSImage (size); image.LockFocusFlipped (control.IsFlipped); drawAction (); image.UnlockFocus (); var ciImage = CIImage.FromData (image.AsTiff ()); if (control.IsFlipped) { var realSize = control.ConvertSizeToBase (size); var affineTransform = new NSAffineTransform (); affineTransform.Translate (0, realSize.Height); affineTransform.Scale (1, -1); var filter1 = CIFilter.FromName ("CIAffineTransform"); filter1.SetValueForKey (ciImage, CIInputImage); filter1.SetValueForKey (affineTransform, CIInputTransform); ciImage = filter1.ValueForKey (CIOutputImage) as CIImage; } var filter2 = CIFilter.FromName ("CIColorControls"); filter2.SetDefaults (); filter2.SetValueForKey (ciImage, CIInputImage); filter2.SetValueForKey (new NSNumber (0.0f), CIInputSaturation); ciImage = filter2.ValueForKey (CIOutputImage) as CIImage; var filter3 = CIFilter.FromName ("CIColorMatrix"); filter3.SetDefaults (); filter3.SetValueForKey (ciImage, CIInputImage); filter3.SetValueForKey (new CIVector (0, color.R, 0), CIInputRVector); filter3.SetValueForKey (new CIVector (color.G, 0, 0), CIInputGVector); filter3.SetValueForKey (new CIVector (0, 0, color.B), CIInputBVector); ciImage = filter3.ValueForKey (CIOutputImage) as CIImage; image = new NSImage (size); var rep = NSCIImageRep.FromCIImage (ciImage); image.AddRepresentation (rep); image.Draw (SD.PointF.Empty, new SD.RectangleF (SD.PointF.Empty, size), NSCompositingOperation.SourceOver, 1); /* Use this when implemented in maccore: ciImage.Draw (SD.PointF.Empty, new SD.RectangleF (SD.PointF.Empty, size), NSCompositingOperation.SourceOver, 1); */ }
public Task <IBitmap> Load(Stream sourceStream, float?desiredWidth, float?desiredHeight) { var data = NSData.FromStream(sourceStream); var tcs = new TaskCompletionSource <IBitmap>(); UIApplication.SharedApplication.InvokeOnMainThread(() => { try { #if UIKIT tcs.TrySetResult(new CocoaBitmap(UIImage.LoadFromData(data))); #else tcs.TrySetResult(new CocoaBitmap(new UIImage(data))); #endif } catch (Exception ex) { tcs.TrySetException(ex); } }); return(tcs.Task); }
public override void AwakeFromNib () { base.AwakeFromNib (); this.StartCheck.Title = Properties_Resources.Startup; this.FinishButton.Title = Properties_Resources.Finish; // this.FinishButton.KeyEquivalent = "\r"; NSImage image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-" + Controller.TutorialCurrentPage + ".png")) { Size = new SizeF (350, 200) }; TutorialView.Image = image; switch (Controller.TutorialCurrentPage) { case 4: TutorialText.StringValue = Properties_Resources.YouCan; OnStart (this); break; } }
public override void FinishedLaunching(NSObject notification) { // load image for the status item string imageFile = NSBundle.MainBundle.PathForImageResource("SysTrayIcon.png"); NSImage image = new NSImage(imageFile); // creating the status item with a length of -2 is equivalent to the call // [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] iStatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(-2); iStatusItem.HighlightMode = true; iStatusItem.Menu = StatusMenu; iStatusItem.Image = image; // create the main configuration window iWindow = new ConfigurationWindowController(); iWindow.LoadWindow(); // create the controller for the application iController = new Controller(this); }
public override void AwakeFromNib () { base.AwakeFromNib (); this.StartCheck.Title = String.Format(Properties_Resources.Startup, Properties_Resources.ApplicationName); this.FinishButton.Title = Properties_Resources.Finish; // this.FinishButton.KeyEquivalent = "\r"; NSImage image = new NSImage (UIHelpers.GetImagePathname ("tutorial-slide-" + Controller.TutorialCurrentPage)) { Size = new SizeF (350, 200) }; TutorialView.Image = image; switch (Controller.TutorialCurrentPage) { case 4: TutorialText.StringValue = Properties_Resources.YouCan; OnStart (this); break; } }
public override void AwakeFromNib () { base.AwakeFromNib (); this.SkipButton.Title = Properties_Resources.SkipTutorial; this.ContinueButton.Title = Properties_Resources.Continue; // this.ContinueButton.KeyEquivalent = "\r"; NSImage image = new NSImage (UIHelpers.GetImagePathname ("tutorial-slide-" + Controller.TutorialCurrentPage)) { Size = new SizeF (350, 200) }; TutorialView.Image = image; switch (Controller.TutorialCurrentPage) { case 1: TutorialText.StringValue = String.Format(Properties_Resources.CmisSyncCreates, Properties_Resources.ApplicationName); break; default: break; } }
public override void AwakeFromNib () { base.AwakeFromNib (); this.ContinueButton.Title = Properties_Resources.Continue; // this.ContinueButton.KeyEquivalent = "\r"; NSImage image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-" + Controller.TutorialCurrentPage + ".png")) { Size = new SizeF (350, 200) }; TutorialView.Image = image; switch (Controller.TutorialCurrentPage) { case 2: TutorialText.StringValue = Properties_Resources.DocumentsAre; break; case 3: TutorialText.StringValue = Properties_Resources.StatusIconShows; break; } }
public static Gdk.Pixbuf GetPixbufFromNSImage (NSImage icon, int width, int height) { var rect = new RectangleF (0, 0, width, height); var rep = icon.BestRepresentation (rect, null, null); var bitmap = rep as NSBitmapImageRep; try { if (bitmap == null) { if (rep != null) rep.Dispose (); using (var cgi = icon.AsCGImage (ref rect, null, null)) { if (cgi == null) return null; bitmap = new NSBitmapImageRep (cgi); } } return GetPixbufFromNSBitmapImageRep (bitmap, width, height); } finally { if (bitmap != null) bitmap.Dispose (); } }
public CocoaBitmap(UIImage inner) { this.inner = inner; }