• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem adding a background NSImageView in a Cocoa View
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem adding a background NSImageView in a Cocoa View


  • Subject: Re: Problem adding a background NSImageView in a Cocoa View
  • From: "tahome izwah" <email@hidden>
  • Date: Fri, 30 Nov 2007 08:46:44 +0100

Hi again Jorge,

just a quick supplemental comment to what I said earlier today: since
this is a Cocoa view AU I need to get the image from the bundle first,
ie. do something like this:

	NSBundle* bundle = [NSBundle
bundleWithIdentifier:@"com.apple.demo.audiounit.WaveformViewDemo"];
	NSImage *anImage = [[NSImage alloc] initWithContentsOfFile:[bundle
pathForResource:@"128" ofType:@"png"]];

Best
--th

2007/11/30, Jorge Castellanos <email@hidden>:
>
> b) The code you wrote below works, but there is an easier and shorter
> way to do it using Cocoa. In drawRect stick the following code:
>
>                 // Load the image.
>         NSImage *anImage = [NSImage imageNamed:@"imageName"];
>
>                 // Find the point at which to draw it.
>         NSPoint backgroundCenter;
>         backgroundCenter.x = [self bounds].size.width * 0.5;
>         backgroundCenter.y = [self bounds].size.height * 0.5;
>
>         NSPoint drawPoint = backgroundCenter;
>         drawPoint.x -= [anImage size].width * 0.5;
>         drawPoint.y -= [anImage size].height * 0.5;
>
>                 // Draw it.
>         [anImage drawAtPoint:drawPoint fromRect:NSZeroRect
> operation:NSCompositeSourceOver fraction:1.0];
>
>
> Hope this helps!
>
> jorge castellanos
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Problem adding a background NSImageView in a Cocoa View (From: Jorge Castellanos <email@hidden>)

  • Prev by Date: Re: Problem adding a background NSImageView in a Cocoa View
  • Next by Date: aggregate device creation
  • Previous by thread: Re: Problem adding a background NSImageView in a Cocoa View
  • Next by thread: aggregate device creation
  • Index(es):
    • Date
    • Thread