当前位置: 首页>>代码示例>>C#>>正文


C# AppKit.NSImage类代码示例

本文整理汇总了C#中MonoMac.AppKit.NSImage的典型用法代码示例。如果您正苦于以下问题:C# NSImage类的具体用法?C# NSImage怎么用?C# NSImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NSImage类属于MonoMac.AppKit命名空间,在下文中一共展示了NSImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetBackgroundImage

 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;
 }
开发者ID:samilamti,项目名称:halloween,代码行数:7,代码来源:MainWindow.cs

示例2: GetImagaDataFromPath

		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);
		}
开发者ID:RafasTavares,项目名称:mac-samples,代码行数:31,代码来源:Texture.cs

示例3: CreateAbout

        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);
        }
开发者ID:rchicoli,项目名称:sparkleshare,代码行数:60,代码来源:SparkleAbout.cs

示例4: OSXSurfaceSource

		/// <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);
		}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:11,代码来源:OSXSurfaceSource.cs

示例5: SparkleWindow

        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);
        }
开发者ID:fontanon,项目名称:SparkleShare,代码行数:30,代码来源:SparkleWindow.cs

示例6: SetupWindow

        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;
        }
开发者ID:Rud5G,项目名称:SparkleShare,代码行数:34,代码来源:SetupWindow.cs

示例7: CreateImageFromByteArray

        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;
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:34,代码来源:DisposableImageFactory.cs

示例8: CreateMultiResolutionImage

		public override object CreateMultiResolutionImage (IEnumerable<object> images)
		{
			NSImage res = new NSImage ();
			foreach (NSImage img in images)
				res.AddRepresentations (img.Representations ());
			return res;
		}
开发者ID:TheBrainTech,项目名称:xwt,代码行数:7,代码来源:ImageHandler.cs

示例9: Create

		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;
		}
开发者ID:lPinchol,项目名称:Reign-Unity-Plugin,代码行数:34,代码来源:MainWindow.cs

示例10: DrawThreePartImage

		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);
		}
开发者ID:Anomalous-Software,项目名称:monomac,代码行数:8,代码来源:NSCell.cs

示例11: ToNSImage

        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;
        }
开发者ID:danclarke,项目名称:AquissUsageChecker,代码行数:8,代码来源:ImageExtensions.cs

示例12: CreateImage

		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;
		}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:10,代码来源:ImageBuilderBackendHandler.cs

示例13: RenderToImageInMemory

 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;
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:12,代码来源:MemoryGraphicsContextWrapper.cs

示例14: Tint

		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;
		}
开发者ID:Exe0,项目名称:Eto,代码行数:52,代码来源:NSImageExtensions.cs

示例15: SparkleSetupWindow

        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 ();
        }
开发者ID:shilga,项目名称:SparkleShare,代码行数:52,代码来源:SparkleSetupWindow.cs


注:本文中的MonoMac.AppKit.NSImage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。