Re: Adding an NSButton to a layer-hosted view

2008-11-14 Thread David Duncan

On Nov 14, 2008, at 10:33 AM, Michel Schinz wrote:


Le 14 nov. 08 à 18:04, David Duncan a écrit :

AppKit doesn't do hit testing via the layer tree, so by moving the  
button's layer, you've desynchronized the graphical location of the  
button with the hit test location of the button. If you want to use  
layer-backed AppKit views, you always need to move them via AppKit  
for the graphical and logical locations to match.


That was the problem indeed, thanks a lot David! Moving the button  
using setFrameOrigin: makes it behave correctly.


I'll also conclude from your answer that putting these NSControl  
instances in my layer-hosted view is legal. Please correct me if I'm  
wrong.



It is legal, and AppKit tries to make sure that nothing bad will  
happen (i.e. you shouldn't crash). In general however, its an easier  
programming model if you either work entirely with Views or entirely  
with Layers. You can mix them, but you have to be careful about what  
your doing. Graphical attributes usually aren't a problem, but  
geometrical ones can be (as you've already found out).

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer and View controls

2008-11-14 Thread David Duncan

On Nov 14, 2008, at 9:12 AM, Fabrizio Guglielmino wrote:


Sorry but I forgot to say my application is for iPhone so I don't need
setWantsLayer:YES, I don't think this make the difference, right?


Layers are always on on iPhone, so yes it makes no difference here.


So, if I understand, I can make a second view outside the first
view/layer with the button (and eventually other controls) and this
will not affected of any animations? If it's true I had not understood
the relation between layer and view, now it's clear.



Right, a layer can only affect itself and its sublayers.
--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Adding an NSButton to a layer-hosted view

2008-11-14 Thread David Duncan

On Nov 14, 2008, at 8:22 AM, Michel Schinz wrote:

This seems to work relatively well, except that the NSButton  
instance does not react to mouse events. For example, it does not  
perform the action or toggle its state when I click on it. Instead,  
my layer-hosted view gets the event (i.e. its mouseDown: method gets  
invoked). I found a partial work-around, which consists in calling  
"performClick:" on the button whenever its layer is the one under  
the mouse when the click happens, but this is not satisfactory (e.g.  
the button does not highlight when the mouse hovers over it, even  
though it should, given how it's configured).



AppKit doesn't do hit testing via the layer tree, so by moving the  
button's layer, you've desynchronized the graphical location of the  
button with the hit test location of the button. If you want to use  
layer-backed AppKit views, you always need to move them via AppKit for  
the graphical and logical locations to match.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer and View controls

2008-11-14 Thread David Duncan

On Nov 14, 2008, at 8:10 AM, Fabrizio Guglielmino wrote:


in some previous posts I was looking for information about CALayer
rotation and now I can rotate layer using core animation.
This mail it's about a strange behaviour, in my simple test I have a
single View and a little image loaded as content of main layer.
in the bottom of View there is a button and when I press this button
rotation starts. The strange behaviour is that also the button rotate
but I set bounds and position of CALafer to be in the middle of the
view and half size of it.



When you configure a view to be layer backed (setWantsLayer:YES) all  
subviews of that view become layer backed as well. Any transforms (in  
this case rotation) that you apply to that layer also affect all  
sublayers (which the layer for your button is).


If you don't want the button to rotation, then you need to place it  
outside of the view/layer that is being rotated.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Can't get CABasicAnimation to explicitly animate "frame" property of CALayer

2008-11-10 Thread David Duncan

On Nov 9, 2008, at 4:04 AM, Oleg Krupnov wrote:


Using Core Animation, I want to make a layer change its position and
size with animation. So I need to use the "frame" property of CALayer,
which is animatable, according to the documentation.



http://developer.apple.com/qa/qa2008/qa1620.html
--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CAOpenGLLayer no Antialiasing?

2008-11-08 Thread David Duncan

On Nov 7, 2008, at 6:13 PM, Nik Youdale wrote:

I am having trouble enabling antialiasing in a CAOpenGLLayer  
subclass. Specifically I am trying to use Multisampling. I have set  
up the pixel format with multisampling enabled, etc. The same  
rendering code works in an NSOpenGLView with multisampling setup in  
the pixel format. (It draws in the CAOpenGLLayer, but sadly no  
antialiasing).


As far as i can tell, both segments of code (see below) should do  
exactly the same thing. Is there something obvious i'm missing? Or  
is it stated somewhere that CAOpenGLLayers don't support  
multisampling?



The CAOpenGLLayer effectively uses render-to-texture as its  
implementation. Multisampling isn't supported on such offscreen render  
targets on Mac OS X 10.5.


You can file a feature request stating your desire for this, but it is  
a known issue and will likely be returned to you as a duplicate.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Enumerating outlets automatically?

2008-11-05 Thread David Duncan

On Nov 5, 2008, at 9:13 PM, Graham Cox wrote:


Is there a way to enumerate the outlets of an object automatically?

In a certain type of controller object I'm finding I'm writing a lot  
of code like this:


[myOutlet1 setEnabled:NO];
[myOutlet2 setEnabled:NO];
... etc for another several dozen outlets ...

If I could get a list of outlets (maybe as a dictionary with the  
ivar name as key) I could probably find much easier ways to do stuff  
to each one. I suspect the answer is no but I thought I'd ask  
anyway...



If the 'enabled' state of all these objects are effectively tied to a  
particular state, then why not use bindings? You could bind the  
enabled state of these controls to a property of your controller  
object and then you just set the property and voila.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CABasicAnimation, CALayers, and rotation

2008-11-04 Thread David Duncan

On Nov 4, 2008, at 4:30 PM, Michael A. Crawford wrote:

By default, positive angle values assigned to a rotation animation  
result in counter clockwise rotation.  Is there a way to cause the  
rotation to occur in the clock-wise direction, with positive  
values?  For example, consider a needle rotating in a compass.  As  
the needle rotates in a clockwise direction the value that the  
needle points to increases (up until it wraps around, of course).



No, Core Animation always rotates counter-clockwise (this is how the  
underlying trigonometric operations work). If you want to rotate  
clockwise, you will have to calculate the changes yourself. You should  
also note that you can rotate outside of the unit circle (0-2π) and  
get the correct value, which is useful for certain effects.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer contents memory leak

2008-11-04 Thread David Duncan

On Nov 4, 2008, at 10:47 AM, Adam Fedor wrote:



On Nov 4, 2008, at 10:05 AM, David Duncan wrote:
While I don't see a leak in here, it can never hurt to simplify  
your code. Try this instead.


Thanks, that is simpler, but it doesn't solve the problem. I've  
tried many things. The easiest way to solve the problem is to  
comment out this line:


//[rootLayer setContents: (id)imageRef];

Unfortunately, the app is not too useful in that case.



As others have said, you should be certain that this really is a  
memory leak. Just because memory usage increases does not indicate a  
leak, and in fact many parts of the OS can cause memory usage to go up  
without leaks as there are a number of in-memory caches that are  
created in order to speed up certain operations. You are likely  
hitting one of these caches.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer contents memory leak

2008-11-04 Thread David Duncan

On Nov 2, 2008, at 9:08 PM, Adam Fedor wrote:


 image = [[NSImage alloc] initWithContentsOfFile: next];
 if (image)
   {
 CGImageRefimageRef = NULL;
 CGImageSourceRef  sourceRef;

 sourceRef = CGImageSourceCreateWithData((CFDataRef)[image  
TIFFRepresentation], NULL);

 if(sourceRef) {
   imageRef = CGImageSourceCreateImageAtIndex(sourceRef, 0, NULL);
   CFRelease(sourceRef);
 }
 [rootLayer setContents: (id)imageRef];
 CGImageRelease(imageRef);
   }
 [image release];



While I don't see a leak in here, it can never hurt to simplify your  
code. Try this instead.


NSURL *url = [NSURL fileURLWithPath:next isDirectory:NO];
if(url != NULL)
{
CGImageRef imageRef = NULL;
	CGImageSourceRef sourceRef = CGImageSourceCreateWithURL((CFURLRef),  
NULL);

if(imgSrc != NULL)
{
imageRef = CGImageSourceCreateImageAtIndex(sourceRef, 0, NULL);
CFRelease(sourceRef);
}
[rootLayer setContents: (id)imageRef];
CGImageRelease(imageRef);
}

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSData dataWithContentsOfFile - freeWhenDone:NO ?

2008-10-31 Thread David Duncan

On Oct 31, 2008, at 12:02 PM, [EMAIL PROTECTED] wrote:

I'm using [NSData dataWithContentsOfFile] to load an AIFF file.  I  
was wondering if there is a way to make it freeWhenDone:NO so I can  
delete the NSData object and keep the bytes.  Audio files can be  
pretty big so I was hoping to avoid having to copy the bytes if  
possible.



Another question might be to ask why are you trying to load the entire  
file into memory? If its of any significant length then that is quite  
a large allocation...

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Binding question

2008-10-28 Thread David Duncan

On Oct 28, 2008, at 12:19 AM, Jean-Nicolas Jolivet wrote:

Now, assuming I want to bind an array of those File objects to a  
Table View, however, what I would like to display in the table's  
column is not the complete path of the file, but just the file name  
(that I get with [filePath lastPathComponent])


What would be the best way to achieve that?  Basically: I want to  
bind my column to a property that doesn't really exist (i.e. only  
part of the filePath property)...



You can use a custom value transformer. You would implement  
+transformedValueClass to return an [NSString class] and - 
transformedValue: to return the lastPathComponent of the passed in  
string. Set the transformer for the binding and you should be set.


There are a few samples that you can reach from the Xcode docs  
demonstrating this (just look up NSValueTransformer).

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Cocoa and Printing (Advanced Q)

2008-10-27 Thread David Duncan

On Oct 26, 2008, at 3:06 PM, Tommy Nordgren wrote:


A specific printer can be used ONLY by a special app.


Any printer that can be seen by Print Center can be used by all  
applications by default. If you are a printer vendor, then you can do  
additional things, but you will need to write to CUPS (the subsystem  
that eventually handles all printing on Mac OS X).



Changing printer settings for an App affects that app only.


Some printer settings are system wide, some are tied to print  
sessions. What settings do you need to change?

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Leaking CGColor objects

2008-10-27 Thread David Duncan

On Oct 26, 2008, at 1:06 PM, DKJ wrote:

In the documentation, the foregroundColor property is defined like  
this:


@property CGColorRef foregroundColor

There's no retain parameter.



Correct, however the property is implemented as if it was retain. This  
is because the compiler will generate a warning (or error, can't  
recall which at the moment) when you declare a retained property for a  
non-Obj-C object - which as far as the compiler can tell is all Core  
Foundation data types.


For the purposes of Core Animation at least, you can assume that all  
properties that operate on Core Foundation data types are retained  
properties and that the appropriate Core Animation object will  
property release them when that object is deallocated. Thus the  
correct way to assign a foregroundColor is


CGColorRef color = CGColorCreateGenericRGB(...);
self.foregroundColor = color;
CFRelease(color);

And you don't need to release it yourself in a custom dealloc method  
(the layer is responsible for that).

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSData and NSImage

2008-10-23 Thread David Duncan

On Oct 23, 2008, at 11:30 AM, Andy Bell wrote:

I have an NSData buffer with valid JPEG data which I can save to  
disk using
writeToFile: and view the image easily.  When I come to create an  
NSImage
object from the same data I get an object returned back from  
initWithData:
but the size property has dumb values.  What does this mean?  Is  
this a

valid NSImage object?



What are the "dumb" values? The size that an NSImage reports are in  
points, not pixels, so if the image is recorded as having a DPI other  
than 72, then you will see values other than the pixel size of the  
image.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Putting an image on a CALayer

2008-10-22 Thread David Duncan

On Oct 22, 2008, at 12:09 AM, Patrick Mau wrote:


On 22.10.2008, at 02:54, DKJ wrote:


Me again. I've been using this code:

NSURL *url = [NSURL fileURLWithPath:fname];
	CGImageSourceRef source =  
CGImageSourceCreateWithURL((CFURLRef)url, NULL);

CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CFRelease(source);

theView.layer.contents = (id)image;

It compiles without complaint, but I'm still not seeing the image.  
I can see the effects of changing other properties of the layer  
(e.g. borderWidth). I've checked that image is not NULL. What am I  
missing here?


You are probably missing a '[theView.layer setNeedsDisplay];'


By default this will obliterate the contents that you have just set.  
Calling -setNeedsDisplay or -display will cause the layer to generate  
content and set the contents property to the result of that operation.  
If you set the contents property manually, you should never call - 
setNeedsDisplay or -display on that layer or the content you set will  
be lost. You can avoid this by implementing some delegate methods or  
subclassing a CALayer, but it is generally easier to avoid the issue  
entirely by maintaining control over the CALayer when doing this.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Yet another CALayer puzzle

2008-10-22 Thread David Duncan

On Oct 22, 2008, at 9:48 AM, DKJ wrote:

I've got myView and myController objects in my nib file. myView is  
an IBOutlet of myController. I put this in the initWithFrame: method  
of myView:


CALayer *rootLayer = [CALayer layer];
[self setLayer:rootLayer];
[self setWantsLayer:YES];

But when I read myView's wantsLayer in the awakeFromNib method of  
myController, I find its value is 0. How did the value get changed?


Your nib probably has setWantsLayer turned off. What ever is in your  
nib is what will be true by the time awakeFromNib is called. Simplest  
solution is to move this setup into -awakeFromNib.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer graphics context

2008-10-22 Thread David Duncan

On Oct 22, 2008, at 8:00 AM, Patrick Mau wrote:

A CALayer itself is not associated with a context. The NSView owns  
the graphics context.


Actually when your in layer backing mode, the CALayer owns the  
graphics context.


The context you are looking for is passed to the  
"drawLayer:inContext" message.


This is true, and covered well in the Core Animation Programming Guide  
<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html 
>


Specifically, the section on Providing Layer Content.
--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Putting an image on a CALayer

2008-10-21 Thread David Duncan

On Oct 21, 2008, at 8:50 AM, Jean-Daniel Dupas wrote:

I'd like to put an image stored in a JPEG file onto a CALayer. It  
seems that I do this by assigning a  CGImageRef to its contents  
property. But how do I get a CGImageRef from a file? Do I make an  
NSData object from the file and do something with that?


dkj


You use ImageIO Framework. See CGImageSource reference.



Specifically, you would do something like this:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]  
pathForImageResource:@"myImage"]];
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url,  
NULL);

CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CFRelease(source);

Do what you will with 'image' and release it when your done.
--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: how to use the loginItem in OSX 10.3?

2008-10-16 Thread David Duncan

On Oct 16, 2008, at 2:27 AM, XiaoGang Li wrote:


hi, list,
I have a task that a cmd-line utility should be launched when user
login window on OSX 10.3.9. this cmd-line utility bind to a socket  
port and
listen message from low-level server. I means that the cmd-utility  
will not
quit until the user logout. acutally, I know I should use launchd  
method to

implement this feature in 10.4 or later . but in OSX 10.3.9, I have
encountered some problems.
At first, I planned to use login Items, add item in the
loginwindow.plist in the user's directory. I can add the cmd-line  
utility to
the login item list of current user when the user login window. but  
one

terminal (console) popup every time. this is a big problem, so
unsatisfied for me, I need it to run as a daemon.
   Second, i use the unrecommended way : add a plist file to the path:
/etc/mach_init_per_user.d directory. but it seems not work. what  
should i do

anything else?
I am sorry that if i put this mail in a wrong list. Any comments  
will

be appreciated. Thanks.



If I'm understanding you correctly, you want to launch a daemon at  
login time on 10.3.9?


First, check out TN2083 Daemons and Agents <http://developer.apple.com/technotes/tn2005/tn2083.html 
>


If you have further questions, I would recommend either asking on  
Darwin-Dev or submitting a tech support incident to [EMAIL PROTECTED]

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer bounds with ResizeAspect mask?

2008-10-09 Thread David Duncan

On Oct 8, 2008, at 11:09 PM, Colin Doncaster wrote:

so I would turn off the animations by updating the frame and  
position within


[CATransaction begin];
[CATransaction setValue: 
(id)kCFBooleanTrueforKey:kCATransactionDisableActions];

[CATransaction commit];

or is there another more correct way?
this seems to work, but I wasn't too sure if there's a  
wantsAnimation type property that could be called on a layer to  
always turn off animation on that layer.



This if fine if you don't always want to disable a particular  
animation. If you wish to alter or disable an animation in all  
contexts, then read the docs on -actionForKey: which describes several  
methods you can use to disable a particular animation for a layer or  
group of layers.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Data Types for Extracting samples from Audio Buffer

2008-10-06 Thread David Duncan
"In audio data a frame is one sample across all channels. If the  
ASBD describes non-interleaved audio, the byte and frame count  
fields describe one channel (mBytesPerPacket would be 2 for non- 
interleaved stereo 16-bit PCM). For interleaved audio, the fields  
describe the set of n channels (mBytesPerPacket would be 4 for  
interleaved stereo 16-bit PCM). In uncompressed audio, a packet is  
one frame, (mFramesPerPacket == 1)."


To be honest this paragraph is less than illuminating, since it  
states if the audio is interleaved it is interpreted one way, if  
not, then in another way, but doesn't say whether you can tell if it  
is interleaved or not - presumably you can using the format flags.  
Also, 32-bit floating point samples are another possibility, so you  
need to examine the flags to find out exactly what it is you've got  
and then use the remainder of the information to determine how to  
turn that into individual samples. I notice that you can also set  
fields in an ASBD then call MovieAudioExtractionSetProperty followed  
by MovieAudioExtractionFillBuffer to convert to your chosen format.  
So if you always do want 16-bit samples, then you need to carry out  
this conversion step.



Graham is correct in his interpretation of the docs. The Core Audio  
SDK had sample code to assist in interpreting many of its structures,  
including the ASBD that is used so commonly. These are C++ classes,  
but they should be easily incorporated into any Cocoa application  
(just change your source files to .mm).


You can find them in /Developer/Examples/CoreAudio/PublicUtility/. The  
helper for ASBDs is the CAStreamBasicDescription class.


Also, if you have significant Core Audio questions, I would recommend  
asking them on the Core-Audio list rather than on Cocoa-Dev, as I'm  
not aware of any Core Audio engineers lurking on this list.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: [Math] sin(), cos() not working? What special magic must I use to summon their powers?

2008-10-01 Thread David Duncan

On Oct 1, 2008, at 5:46 AM, Michael Robinson wrote:


Unsurprisingly, I need my hand held again.

1. how do I initialize a CGShading object, with my two colours (left  
right/top bottom)


See the Quartz 2D Shadings sample at <http://developer.apple.com/samplecode/Quartz2DShadings/index.html 
>
The sample code runs on 10.5, but the shadings code should work on  
10.4 as well (the sample only runs on 10.5 because it also uses the  
CGGradientRef APIs).



2. how do I fill my NSBitmapImageRep with this pretty gradient?



Create an NSGraphicsContext with the image rep, then get the CGContext  
from the NSGraphicsContext. The latter is shown in the sample above,  
although the former is not.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Image processing in Cocoa

2008-09-25 Thread David Duncan

On Sep 25, 2008, at 3:52 AM, Christian Giordano wrote:


I think I found what to do. I need to create a bitmap context from the
bitmap and drawing there. It makes sense that everything drawn is
handled by contexts of course, I'm just a bit concerned about
performances.



Internally NSImage will basically do the same thing - create a  
CGContext to draw the other content into it. The performance shouldn't  
be an issue in the vast majority of use cases. I'm not convinced that  
alternatives would actually create a significant speed up, and the  
additional code required to make it work universally would likely make  
any of those cases less optimal than what the OS already provides.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do I get CAScrollLayer to draw its sublayers

2008-09-22 Thread David Duncan

On Sep 21, 2008, at 3:39 PM, Cesar Alaniz wrote:

I have set up a CAScrollLayer with one sublayer, in this case a  
CATiledLayer.  The documentation say's that CATiledLayer will call  
drawLayer:(CALayer*)layer inContext:(CGContextRef) ref as the layer  
is needed to be drawn.   I cannot see this method being called  
currently.  My CAScrollLayer, the superlayer has  
setNeedsDisplayOnBoundsChange set to YES and a delegate set to draw  
the content.  The delegate method drawLayer inContext for the scroll  
layer is being called.  Do i need to do something special to make it  
redraw CATiledLayer's layer?



You need to call -setNeedsDisplay on the tiled layer. Doing so on the  
scroll layer will only affect its own contents.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Drawing an NSImage in a CALayer

2008-09-19 Thread David Duncan

On Sep 19, 2008, at 10:48 AM, Matt Long wrote:

p.s. I would defer to David Duncan on the CGImageRef creation  
overhead. I'm sure he's right. I just didn't have the time to try to  
get his code to work. ;-)



I forgot to set the current context :). More complete code here,  
although this doesn't take the real resolution of the image into  
account (-size returns a value in points, not pixels).


-(CGImageRef)nsImageToCGImageRef:(NSImage*)nsimage;
{
NSSize imageSize = [nsimage size];
	CGColorSpaceRef genericRGB =  
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
	CGContextRef context = CGBitmapContextCreate(NULL, imageSize.width,  
imageSize.height, 8, 0, genericRGB, kCGImageAlphaPremultipliedFirst);
	NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext  
graphicsContextWithGraphicsPort:context flipped:NO];

[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:nsGraphicsContext];
[[NSColor yellowColor] setFill];
NSRectFill(NSMakeRect(0.0, 0.0, imageSize.width, imageSize.height));
	[nsimage drawAtPoint:NSZeroPoint fromRect:NSZeroRect  
operation:NSCompositeCopy fraction:1.0];

[NSGraphicsContext setCurrentContext:nsGraphicsContext];
CGImageRef image = CGBitmapContextCreateImage(context);
CFRelease(context);
return image;
}

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Drawing an NSImage in a CALayer

2008-09-18 Thread David Duncan

On Sep 18, 2008, at 3:33 PM, Brad Gibbs wrote:


The PNG is in the main bundle -- in my Resources folder.


You can do this to get a CGImageRef directly. (written in Mail, no  
error checking).


CFURLRef imageURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(),  
(CFStringRef)@"myImage.png", NULL, NULL);
CGImageSourceRef imageSource = CGImageSourceCreateWithURL(imageURL,  
NULL);

CFRelease(imageURL);
CGImageRef image = CGImageSourceCreateImageAtIndex(imageSource, 0,  
NULL);

CFRelease(imageSource);

Then you can assign 'image' to your layer's contents.

On Sep 18, 2008, at 3:18 PM, Matt Long wrote:


Use this code:

- (CGImageRef)nsImageToCGImageRef:(NSImage*)image;
{
   NSData * imageData = [image TIFFRepresentation];
   CGImageRef imageRef;
   if(imageData)
   {
   CGImageSourceRef imageSource =
 CGImageSourceCreateWithData(
   (CFDataRef)imageData,  NULL);

   imageRef = CGImageSourceCreateImageAtIndex(
  imageSource, 0, NULL);
   }
   return imageRef;
}



While this code is popular, I wouldn't recommend it as a general  
conversion. Creating a TIFF representation in order to generate a  
CGImageRef is going to be considerably more costly than a more direct  
alternative. Instead I would recommend creating a CGBitmapContext,  
drawing the NSImage to it and then extracting a CGImageRef from the  
bitmap context. Something like this (again, written in Mail, no error  
checking).


CGColorSpaceRef genericRGB =  
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
CGContextRef context = CGBitmapContextCreate(NULL, desiredWidth,  
desiredHeight, 8, 0, genericRGB, kCGImageAlphaPremultipliedFirst);
NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext  
graphicsContextWithGraphicsPort:context flipped:NO];

[NSGraphicsContext saveGraphicsState];
[myNSImage drawAtPoint:NSZeroPoint fromRect:NSZeroRect  
op:NSCompositeCopy fraction:1.0];

[NSGraphicsContext setCurrentContext:nsGraphicsContext];
CGImageRef image = CGBitmapContextCreateImage(context);
CFRelease(context);

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Drawing an NSImage in a CALayer

2008-09-18 Thread David Duncan

On Sep 18, 2008, at 2:54 PM, Brad Gibbs wrote:

I'm trying to draw an NSImage (a PNG) in a CALayer.  The goal is to  
create a method that allows me to pass an NSImage as an argument to  
create a layer-hosting view.  I have:


Where is this PNG originating? The answer may mean a simpler (and  
potentially faster) method can be used...



[imageLayer drawLayer:imageLayer inContext:ctx];


You don't call this function yourself. You set the delegate on the  
CALayer and you implement this method. When the CALayer needs image  
content it will be called automatically with the correct parameters.  
This is usually as a result of a -display message being sent to the  
layer (which is typically arranged for by sending -setNeedsDisplay).

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Drawing on Another App's CGDisplayCapture

2008-09-16 Thread David Duncan

On Sep 16, 2008, at 3:44 PM, Greg Hoover wrote:

I'm building a very similar function to the one described by Ben,  
but using PowerPoint -- I have an overlay window that is supposed to  
show auxiliary info during a PowerPoint presentation.  I've verified  
that the drawing routines are running on my overlay window, but the  
updates are never shown on the screen (I assume because PowerPoint  
captures the display).  From other postings it seems to be that  
there is no way to promote the redrawn state of the overlay window  
to the screen until the app releases the display, yes?  Are there  
any known workarounds for this?



If the application is truly capturing the display, then no you cannot  
draw over that application. However, it is possible that the  
application is simply putting a window above yours (and all others) in  
which case you simply need to change the window level of your window.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Animate a CGPath

2008-09-12 Thread David Duncan

On Sep 11, 2008, at 12:21 PM, Daniel Weber wrote:

Hi everyone. I have an NSView with some appkit drawing code that I'm  
trying
to convert to core graphics drawing code. One thing I'm having  
trouble with
is the transition from NSBezierPath to CGPath. Basically in my  
application,
I want to animate the drawing a curve. In other words, I want to  
show the
path being drawn over a relatively long period of time (about 2  
seconds).
When I was using NSBezierPath, I would do this by first flattening  
the path,
then using a timer to call the draw method to draw elements 0 to 1,  
then 0

to 2, then 0 to 3, and so on until I reached the end of the curve. The
effect was that the user could see the curve being "animated". Is  
there a
way to "flatten" a CGPath? Is there another way to do this in Core  
Graphics?


It sounds like what you want is CGPathApply(). It will allow you to  
break a path down into its components and do whatever you please.


That said, it is probably cleaner to simply draw the individual  
components yourself rather than using a CGPathRef, as all of the path  
operations have equivalent functionality that can be done directly on  
the context.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSDate autorelease problem

2008-09-03 Thread David Duncan

On Sep 3, 2008, at 10:02 AM, [EMAIL PROTECTED] wrote:

This is being called from an audio play back proc which is being  
called about 100 times a second.  I'm getting this error message in  
the log window a whole bunch of times.



The audio proc should gives you a time stamp that you can use  
(presuming your talking about Core Audio). Any reason you can't use  
that?

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Changing the default audio output hardware

2008-09-03 Thread David Duncan

On Sep 3, 2008, at 8:17 AM, Half Activist wrote:

	Does anybody know how to change the system's default sound output  
programatically speaking of course ;-)


Generally, you don't, this is a user preference. If you want to  
produce sound from a selected output device, then you can use Core  
Audio to enumerate and choose a device. I believe Quicktime also  
allows you to specify a device for output if your using it. Either way  
you will probably get better answers on the Core Audio list, or the  
Quicktime API list if your using Quicktime, but either way you will  
probably need to explain what you are trying to accomplish in more  
detail.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Font Color In CTLineDraw?

2008-09-02 Thread David Duncan

On Sep 2, 2008, at 7:43 PM, Mike Rossetti wrote:


[attrString addAttribute:NSForegroundColorAttributeName
   value:[NSColor lightGrayColor] // No effect.
   range:NSMakeRange(0, [attrString length])];



Rendering a font with an NSColor attribute requires a current  
NSGraphicsContext. If you don't have one, then it will take the color  
form the CGContextRef instead.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: converting from decimal to hexadecimal

2008-09-02 Thread David Duncan

On Sep 2, 2008, at 9:45 AM, Ronnie B wrote:


Is there an easy way to convert a decimal number to hexadecimal.
NSNumberFormatter does not have an api for that.  Any advice.



See the formatting methods on NSString: <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html 
>

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Semi-transparent, blurred NSWindow background?

2008-08-25 Thread David Duncan

On 25/08/2008, at 2:45 AM, Tim Andersson wrote:

Is there any way of creating a NSWindow that has a semi-transparent,  
blurred background? With "blurred background" I mean that whatever  
you see through the window/background is distorted (blurred).


There isn't a particularly fast way to do this, although I have  
experimented with it a bit in the past. You can use the CGWindow API  
to read the contents under your window and apply a blur to them using  
Core Image directly or indirectly via Core Animation, but in either  
case you'll see the Window Server spending considerably more CPU time  
as it has to re-render the contents under your window. You could fake  
it by updating the image rarely but there isn't a particularly good  
way to completely mitigate the CPU usage.


On Aug 24, 2008, at 9:13 PM, Rob Keniger wrote:

In 10.5 you can add any core image filter to a window using the  
private function 'CGSAddWindowFilter'.



Please do not use private API, they are subject to change in ways that  
can break your application on any OS update. File a feature  
enhancement request describing what you wish to do instead.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Obtaining rotation from CTM

2008-08-21 Thread David Duncan

On Aug 21, 2008, at 6:56 AM, Tilman Bender wrote:

Is it possible to obtain the angle of rotation from a tranformation- 
matrix created with CGAffineTransfrom?


If the CTM consists of only rotation and transform (or if it is scaled  
and you know the scale values) then it should be possible to reverse  
one. However...



Background:
I am building a simple kitchen-timer app, that should work like the  
ones in your mom's kitchen:
You set the time by touching a control and rotating it. Now I would  
like to obtain  the current

angle of my clock.

I know how to use and create CGAffineTransform stuff, but I am not  
really familiar with the extraction of specific information from

such a matrix.



I would highly recommend that you retain the rotation as part of your  
data model instead of trying to extract it from the CTM. Not only  
that, but if your concatenating lots of rotations to your transform  
matrix in order to do the rotation, then your losing precision that  
can eventually cause your transform to do very weird things, causing  
odd graphical glitches.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: !foo vs foo == nil

2008-08-20 Thread David Duncan

On Aug 20, 2008, at 3:23 PM, Torsten Curdt wrote:

This question has come up during the last CocoaHeads and no one was  
really able to give a definite answer.

Do both expressions really mean the same thing (as nil is not null)?



nil == 0. 0 is false, !0 is true. 0 == 0 is true. Therefore they are  
equivalent :).

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Tiger Compatible OpenGL Screenshot Code

2008-08-20 Thread David Duncan

On Aug 20, 2008, at 10:39 AM, Eric Hoaglin wrote:


http://developer.apple.com/samplecode/OpenGLScreenSnapshot/index.html
(Leopard+)



The basic technique from this sample should work on 10.4 (the previous  
version of this sample did) but it wasn't qualified against 10.4 for  
the latest release, so it wasn't stated as capable of being able to  
run on 10.4. I would try linking against the 10.4 SDK and seeing what  
you get.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Calling an object from a C function

2008-08-19 Thread David Duncan

On Aug 19, 2008, at 4:28 PM, Charlie Dickman wrote:


from within a C (not Objective C) function and make use of the result?

In Objective C I would invoke

[myObject myMethod: myInt];



You invoke it exactly the same way. There is no difference. But you  
need to compile as Obj-C.


int foo(id bar) { [bar foobaz]; }
--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Calling an object from a C function

2008-08-19 Thread David Duncan

On Aug 19, 2008, at 2:53 PM, Gilbert Mackall wrote:

I have a C function from which I would like to call a method. I  
can't find any documents the cover how to do this.


You call it just like you call any other method. Your C function will  
need to be compiled with the Obj-C compiler however. Easiest way to do  
this is to name the source file with a .m extension.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CATiledLayer documentation

2008-08-18 Thread David Duncan

On Aug 18, 2008, at 10:54 AM, Houdah - ML Pierre Bernard wrote:

Unfortunately, the sample code left me confused. Seems to me that  
your drawing method always does the same thing. I find no notion of  
tiling. Obviously there is: when I set a breakpoint on the drawing  
method I can clearly see the view being drawn bit by bit. I just  
don't understand how it works.


Actually, thats the intended model. When a tiled layer calls on its  
delegate's -drawLayer:inContext: (or its own -drawInContext:) method,  
the context has already been transformed and clipped to capture what  
is necessary for the tile that its drawing. This allows for a model  
where you don't have to be concerned with the tiling if you don't want  
to be.


If you do want to be concerned with the tiles, then you can use  
CGContextGetClipBoundingBox() to determine the tile that you are being  
asked to draw. If your using the level of detail as well, you can  
either use that same clip box (carefully) to deduce the scale, or use  
CGContextGetCTM() to get the current transform matrix and use that to  
deduce the scale (although this relies on certain assumptions about  
the CTM that will be applied).


Of course, I would have hoped for an example with multiple image  
source containing tiles.



Noted. :).
--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Delayed termination to allow release

2008-08-11 Thread David Duncan

On Aug 11, 2008, at 11:33 AM, Trygve Inda wrote:


My main thread creates a few other objects which have NSThreads and/or
timers. I have found that when I quit the app, and the threads are  
ended,
something in the OS is retaining my objects for a bit... They end up  
never
being dealloc'd which messes a few things up as some data is written  
to disk

at this point.



-dealloc is short circuited when an application is quit (as  
deallocation is going to occur due to the application's memory space  
going away).


You should arrange for things that need to occur on application quit  
to occur in -applicationShouldTerminate: without relying on object  
lifetimes to do this (if you ever write a GC enabled application you  
will find you have the same issues in that you cannot message an  
object in -finalize reliably).

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How to obtain NSApplication from kCGWindowOwnerPID?

2008-08-08 Thread David Duncan

On Aug 8, 2008, at 11:46 AM, Stefan Hafeneger wrote:

I would like to figure out the NSWindow object for a screen  
location. I could use CGWindowListCopyWindowInfo() to obtain a list  
of all visible windows and consequently the bounds of each window,  
the (window server's) window ID and the PID. I don't want to get a  
pointer to the NSWindow or NSApplication object, but I would like to  
check for a specific application if this window belongs to this  
application and so get the NSWindow object. Since I already got low  
level information about the window and process I don't want to  
iterate over all NSWindows of NSApplication and do a hit test. Any  
ideas?



What are you really trying to do? You can't get access to another  
processes' NSApplication or NSWindow objects (not to mention not all  
processes with windows have either of these objects).

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CGImageSourceCreateFromURL failed with error -11

2008-08-06 Thread David Duncan
Couldn't tell either of you why your having issues without seeing  
code, and probably not even then, but this is probably worth a bug  
report.


On Aug 6, 2008, at 1:52 PM, James Trankelson wrote:


I'm having the exact same problem. Loading collections of small images
(jpeg in my case).

On Tue, Aug 5, 2008 at 2:32 AM, Nicolas Zinovieff <[EMAIL PROTECTED]>  
wrote:

David,

the images are GIFs, roughly 40KB each, 200x100 (or 100x200).
Nothing fancy.



--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CGImageSourceCreateFromURL failed with error -11

2008-08-04 Thread David Duncan

On Aug 4, 2008, at 3:58 PM, Nicolas Zinovieff wrote:


On 04 Aug 2008, at 18:54, David Duncan wrote:

How is CGImageSourceCreateWithURL failing with any error when its  
return value is a CGImageSourceRef and not an OSStatus?


Well, it returns NULL, and prints in the console that it failed with  
error -11... And that takes a very long time to return, too.



What types of images are you trying to load?
--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CoreFoundation Command Line Tool - an easy beginner question

2008-08-04 Thread David Duncan

On Aug 4, 2008, at 2:00 PM, Michael Ash wrote:


I think you may have missed the read() at the beginning of the
function, which is critical to the operation of the tool. (The purpose
is to wait for the parent process to quit, then restart it.) If,
however, I have instead missed a way to make the "open" tool wait for
its parent to die before opening the argument, I would very much
appreciate enlightenment on that subject.



Ah, I think you might want to make the parent process a launchd agent  
instead then. I'm not completely familiar with the intricacies of this  
(nor the problem to be solved in general) but it is capable of  
relaunching a process when necessary, and it will also auto-throttle  
the relaunch if the process is being troublesome (i.e. dying over and  
over and over in a short time).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CoreFoundation Command Line Tool - an easy beginner question

2008-08-04 Thread David Duncan

On Aug 4, 2008, at 11:51 AM, Steve Cronin wrote:


Folks;

I open new project using the  CoreFoundation - Command Line Tool  
template, and place the code shown above.


I've tried various usages of #import  but  
can't seem to get it right so that NSURL & NSAutoreleasePool are  
defined...
I believe that both NSURL and NSAutoreleasePool are defined in the  
Foundation framework, which is why I am focused on getting it  
#imported,  I just need the syntax..

(with Foundation framework added to the project)
NO --> #include   (~700 errors...)
NO --> #include   (45 errors..)

Oh out of exasperation, I tried  ---> ~1700 errors



My guess would be that the compiler thinks its compiling C (or C++)  
code, when you've given it Obj-C. Simplest fix if that is the case is  
to change the file extension to ".m". But without seeing the actual  
errors, it would have to remain a guess.


Alternatively, you can keep this all in the land of C by using  
CFURLCreateWithFileSystemPath() and CFStringCreateWithCString(). Then  
you won't need any Obj-C (or Foundation) at all.


Of course, while I realize this is probably a learning project, the  
same thing can be accomplished with the "open" command line tool :).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CGImageSourceCreateFromURL failed with error -11

2008-08-04 Thread David Duncan

On Aug 4, 2008, at 4:00 AM, Nicolas Zinovieff wrote:

I have this app that constantly updates a series of thumbnails in  
the background for a Cocoa view.
When I have less than, say, 40 items in there, there is no problem  
at all.
If I add three times that many elements, CGImageSourceCreateWithURL  
fails with error -11



How is CGImageSourceCreateWithURL failing with any error when its  
return value is a CGImageSourceRef and not an OSStatus?

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer and CGContexts

2008-07-30 Thread David Duncan

On Jul 30, 2008, at 9:50 AM, John Clayton wrote:

I'm wanting to create a CGImageRef from a quartz based CGContextRef,  
so that I can feed a CALayer with it.   Is there a preferred way of  
doing this?  I did think of creating a CGLayer, drawing into it's  
context, and then creating a CGImageRef via a CIContext  
createCGImage:inRect: call - is that recommended?  Or is there a  
simpler way?


If you have a bitmap context, you can just call  
CGBitmapContextCopyImage() to get an image you can use from it. Can  
you explain your situation a bit more?

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Storing values in dictionary with their address as the key

2008-07-28 Thread David Duncan

On Jul 28, 2008, at 12:32 PM, Carter R. Harrison wrote:

The issue was with the format string.. Instead of a %x, I needed a  
%qx.  The %qx displays a 64 bit address whereas the %x displays a 32  
bit address.  When you give %x, only the least significant 32 bits  
are printed and those happen to always be the same (at least in my  
case).



If you use %p it will do the right thing with 32-bit vs 64-bit  
pointers. However as others have said, you should pass myObject not  
&myObject if you really want to use NSString keys (instead of NSValue  
keys).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Retrieving the current -[NSShadow set]

2008-07-25 Thread David Duncan

On Jul 25, 2008, at 3:59 PM, Keith Duncan wrote:


That's actually the original question. How does one do this?



You don't. If I were doing this, I would simply pass the shadow  
parameters into the function (and create conveniences for myself if I  
were so inclined).


The ability for NSShadow to provide you with its shadow parameters is  
in part due to its implementation, as it needs to retain these values  
in order to implement -set. From the Quartz side of things, -set  
effectively equates to a call to CGContextSetShadowWithColor() which  
sets all of these parameters at once. But there is no method to  
retrieve these parameters from either the NSGraphicsContext or  
underlying CGContextRef.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSTask

2008-07-22 Thread David Duncan

On Jul 22, 2008, at 2:49 PM, Torsten Curdt wrote:

I was looking into the cancelation of the thread. (isCanceled/cancel  
since 10.5) And just noticed that I don't have the reference to the  
NSThread - at least not when using detachNewThreadSelector. And then  
I was wondering how you would get access to the instance on 10.4.  
(10.5 you can create and start the NSThread via init/start)



Most of the instance methods of NSThread are not available prior to  
10.5. Those that are you would call within the thread by calling  
+currentThread or you would call one of the other class methods of  
NSThread.


Or in other words, prior to 10.5 there isn't anything you can really  
do with an NSThread instance that would warrant needing access to the  
actual instance from outside of the thread itself.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-21 Thread David Duncan


On Jul 20, 2008, at 4:04 PM, Rick Mann wrote:

David, I checked my code again, and realized I was setting the bias  
to 1 (I thought I saw that in a sample). I don't really understand  
how the numbers are interpreted, but when I set it higher (4, and  
then 10), my layers started getting redrawn.



Its all powers of 2. Levels of detail is how many of them you have,  
starting at 1. So if you set levelsOfDetail to 3, then you have 1,  
1/2, 1/4. If you set it to 7 you add 1/8, 1/16. This effectively means  
you have smaller representations of your data.


levelsOfDetailBias biases levelsOfDetail so that you can scale up as  
well as down. So if we go back to levelsOfDetail set to 3, but set  
levelsOfDetailBias to 1, then you get instead 2, 1, 1/2. If you set it  
to 2, then you get 4, 2, 1. Setting this value greater than  
levelsOfDetail-1 is may work (haven't tried it) but doesn't really  
give you anything.


 Effectively together you get the powers of 2 from  
2^(levelsOfDetailBias) to 2^(levelsOfDetailBias-levelsOfDetail+1) for  
your representations.


I'm not even sure I see a way to do that by writing my own animators  
& renderers (I can't figure out how to subclass CARenderer, anyway).


You wouldn't want to subclass CARenderer anyway, I can't imagine  
anything useful that you could get out of doing so.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Newbie CALayer Questions

2008-07-21 Thread David Duncan

On Jul 21, 2008, at 9:49 AM, Scott Anguish wrote:


On 21-Jul-08, at 10:48 AM, Bob Barnes wrote:

 I hadn't considered that but I cut and pasted it directly from the  
documentation.


- (void)drawInContext(CGContextRef)ctx {
  NSLog(@"drawInContext called");
}


that should be

- (void)drawInContext:(CGContextRef)ctx



Also keep in mind that if you are using a delegate, you implement:

-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: QCCompositionLayer for Manipulating other CALayers

2008-07-18 Thread David Duncan

On Jul 17, 2008, at 7:50 PM, Mike Rossetti wrote:

Before I spend a lot of time attempting the following I would  
appreciate any advice based on your experience:


I've got a drawing-like application where I'd like the user to be  
able to rotate individual elements of the drawing.  When the mouse  
is hovering over an element I draw a manipulation image (a CALayer)  
and what I'd like to do is to let the user mouse click in a little  
rotator control nubby and drag to rotate.


I'm considering using a QCCompositionLayer and pulling in a nice  
Quartz Composition I put together that behaves (at least in Quartz  
Composer) as I'd like.


Is this a foolish or a wise direction to take?



There is nothing built in to do this, so you'd have to figure out some  
way to express your render tree to the QCComposition (or at least part  
of it) so that it can output the manipulations so you can then apply  
them to the layer. I don't think this will work very well honestly,  
and I think it would likely be easier for you to replicate this  
functionality in code (both in terms of the amount of code to support  
this and the effort required to make it work correctly).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-16 Thread David Duncan

On Jul 15, 2008, at 10:42 PM, Rick Mann wrote:

However, at the time that my drawing code is called, the  
CGContextRef that's handed to me is NOT scaled. So my drawing is  
done small, and then only scaled afterward by some blit operation.  
The result is very pixilated lines.


If you are dealing with CALayers, then the context covers the number  
of pixels defined by layer.bounds.size. If you are dealing with a  
CATiledLayer, then the context passed covers the number of pixels  
defined by layer.tileSize. The primary difference between a CALayer  
and a CATiledLayer is that the tiled layer has multiple  
representations for the same content, whereas a CALayer has only one  
representation (which is also why a CATiledLayer requires more  
resources than a CALayer).


This is also why when you scale up a CALayer its content its content  
looks interpolated - its the same number of pixels as before, just  
interpolated larger. If you exceed the maximum LOD of a tiled layer,  
you will see the same thing (which if you don't set a LOD bias means  
if you scale a tiled layer above 1.0 it will also have its content  
interpolated).


I've tried making my root layer a CATiledLayer, and I've tried  
making my individual sublayers CATiledLayers (and setting levels of  
detail for both). Nothing works.


I'm not certain why it would not, at least not with all your layers as  
tiled layers. If just your root layer is a tiled layer, then it would  
need to be transformed for its drawing code to be re-invoked, and it  
would not effect any of the sublayers directly.


I don't really want to have to set the scale on each sublayer; this  
seems to defeat the purpose of the drawing transform.


This wouldn't have the effect you would want anyway (both transforms  
would be concatenated, which would end up with an explosion of size  
unless you flattened your layer hierarchy)


The documentation says that any transform applied to a layer also  
applies to its sublayers, but this is not what I'm seeing; at least,  
not at draw time.



Can't really say what you are or are not seeing here, I'd probably  
have to see code. If this is critical, I'd recommend filing a DTS  
incident.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer transform, setting the Y value of rotation causes side-effects

2008-07-14 Thread David Duncan

On Jul 14, 2008, at 9:57 AM, John Clayton wrote:


Huh?

Question 1: Why do X and Z get very close to PI?
Question 2: Why does Y end up being 1.02 when I set it to 2.12041?

Does anyone know what's going on here?  I'm a little stumped by this  
one.



The simple answer is that with a 4x4 rotation matrix, there are a  
number of distinct matrices that are mathematically equivalent. Note  
that 3.14 - 2.12 = 1.02 and that X & Z were flipped 180 degrees.  
Effectively your seeing the solver for reversing an arbitrary 4x4  
matrix into x/y/z rotations making certain simplifying assumptions  
that don't match what you are expecting.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Remove overlap on NSBezierPath

2008-07-13 Thread David Duncan

On Jul 13, 2008, at 6:43 AM, Georg Seifert wrote:


I don’t know if this is the right place to ask ...

How I can merge to bezierPaths  and remove the overlap in Cocoa.  
Does anyone has exerience with this or can point me to some  
information?



Now one thing that no one has really asked is, do you need a  
mathematical representation of this, or just a graphical representation?


If you just need a graphical representation, then you might be able to  
do this by drawing both beziers and then manipulating the blend mode  
to draw what you want. I haven't tried this myself, and I haven't  
thought too much about it beyond that it might be easier in the  
graphical domain, but if all you need is graphics, then consider the  
issue to be a graphical one rather than a mathematical one.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: any other type of value for the "fromValue" property of CAAnimation?

2008-07-11 Thread David Duncan

On Jul 11, 2008, at 5:38 AM, Cloud Strife wrote:

I am wondering whether I could set  this property to NSColor or  
CGColor
inorder to change the layer color dynamically. For example, If I  
want to
change a Green layer to a red one from time to time, could anyone  
give me a

guidance?



CGColorRefs are Core Foundatation data types, and therefore analogous  
to NSObject decedents, thus you can typecast a CGColorRef to an id and  
assign it as a fromValue or toValue of a CAAnimation without needing  
to do any kind of conversion. Note however that NSColor and CGColorRef  
are NOT toll-free bridged, therefore it is an error to assign an  
NSColor where a CGColorRef is expected (or vise versa).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: dataWithPDFInsideRect: ignores alpha of a shading?

2008-07-10 Thread David Duncan

On Jul 10, 2008, at 5:47 AM, Graham Cox wrote:

I've noticed that when generating PDF data from a view with - 
dataWithPDFInsideRect:, transparent flat colours work OK, but  
gradients (CGShading) that have some colours that are not 100%  
opaque are not recorded correctly (the alpha is ignored and the  
colours are always 100% opaque).


Is this a known issue?



I think it would help of you filed a bug about this, I'm not certain  
if there is one already filed. If your shading uses a constant alpha  
value, I think you can work around this by using CGContextSetAlpha()  
to draw the shading with the target alpha (and making the shading  
itself opaque).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-09 Thread David Duncan

On Jul 9, 2008, at 2:08 PM, Rick Mann wrote:


On Jul 9, 2008, at 12:59:33, David Duncan wrote:

Given what it sounds like your content is, I might consider putting  
the whole canvas on a single or small set of tiled layers (they can  
be unbounded in size).



Oh. I had thought making each individual part its own CALayer was  
most appropriate. I intend for each part to change its appearance to  
reflect selection, hover, etc, as well as be draggable, rotatable,  
etc. Animating these these changes seems to dictate making each its  
own layer.


Now, I'm not really sure how to animate something I'm drawing  
directly (for example, when you're hovering over a part, I would  
like it's "significant contour" to pulsate, or something like that).



Either method should work, but you may want to consider resource usage  
in both as well. Its certainly plausible to logically pull something  
out of its parent layer (i.e. redraw it into another layer) when  
selected, then when deselected burn it into the model so its drawn on  
its parent layer again.


But its mostly an implementation detail. I would probably go with what  
works first, then if you find a performance issue to consider a change  
then. As always, premature optimization is to be avoided.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-09 Thread David Duncan

On Jul 9, 2008, at 11:09 AM, Rick Mann wrote:

My CAD program has a number of "parts" laid out on the canvas at the  
whim of the user. These parts are interconnected by the user with  
lines comprised of a series of orthogonal line segments (it's  
schematic capture CAD). There is one instance of my CALayer subclass  
for each of these parts, and I'm thinking I'll use one for each  
connected set of line segments (not sure yet).


Given what it sounds like your content is, I might consider putting  
the whole canvas on a single or small set of tiled layers (they can be  
unbounded in size).


Are you suggesting that each of these should subclass CATiledLayer  
instead (or provide a delegate)? I was setting the transform on the  
window's (root?) layer. Will that result in tile sublayers redrawing  
their content?


A tiled layer will trigger redraws when it detects that higher (or  
lower) resolution content is available. It caches this drawing as  
well, so you won't get called to redraw just because of a resize of  
content at that level is already available.


--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-09 Thread David Duncan

On Jul 8, 2008, at 10:53 PM, Rick Mann wrote:

I'm trying to use scaling of the superlayer to implement a zoom  
feature in my CAD app. The various elements in the canvas are drawn  
by a CALayer subclass I have, which overrides drawInContext:. After  
the zoom finishes animating, I want CA to call all the sublayer's  
drawInContext: methods as necessary to re-render the layer's  
contents. Is there any way to do this, short of keeping track of all  
the layers myself and calling setNeedsDisplay on them?



Your best solution for rendering multi-representational content in  
Core Animation is to use a CATiledLayer. It will automatically be  
called to update content as you zoom in and out (assuming you specify  
that the level of content exists). The drawing model is exactly the  
same as with a CALayer, although you can optimize the drawing a bit  
with a bit more knowledge.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Layer Backed Views and CoreAnimation neither animate nor stay in place

2008-07-05 Thread David Duncan

On Jul 5, 2008, at 8:34 AM, Uli Kusterer wrote:


On 27.06.2008, at 14:56, Chilton Webb wrote:
(1) If I specify that I want anything other than the main view to  
have a layer, that view will instantly 'pop' to the foreground in  
the window. However, its actual view remains in the same place in  
the view hierarchy.


 As far as I've seen so far, whenever a new layer is created, it is  
inserted in the front. The only way I've found to fix it is to set  
the zPosition of each view's layer manually. However, luckily that  
seems to work :-)



You can use -insertSublayer:[atIndex: | below: | above:] to put a  
layer in a specific ordering in the layer tree. This is generally  
cheaper than changing the zPosition, as a change in zPosition forces  
the sublayer list to be depth sorted.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Using deprecated methods

2008-07-05 Thread David Duncan

On Jul 5, 2008, at 5:08 AM, Keith Blount wrote:

I am currently overhauling printing in my application. I have a page  
layout accessory view and I now also want to add a print panel  
accessory view. My app runs on both Tiger and Leopard. - 
setAccessoryView: works on both Tiger and Leopard, for adding an  
accessory view to both NSPageLayout and NSPrintPanel. However, in  
both cases, -setAccessoryView: was (rather frustratingly in this  
case, I feel, as it worked fine) informally deprecated on Leopard.  
Instead, we are advised to use -addAccessoryViewController:, which  
uses an NSViewController. But the NSViewController class doesn't  
even exist on Tiger, so subclassing it and having it in the project  
will cause the app not to run on Tiger at all. I don't want a  
different build for both Tiger and Leopard, of course, So, what is  
the proper way of handling this? The path of least resistance is to  
use -setAccessoryView: and hope it doesn't get formally deprecated  
on Snow Leopard, and continues to work for a while
despite its deprecated status. But that obviously isn't the *best*  
(or correct) way of doing things. Any alternative is going to be  
more complicated and involve having separate elements of code for  
Tiger and Leopard, which isn't ideal, but I would love to know the  
established way of handling this.



To handle a case like this, you are going to have to create a bundle  
that you link against the 10.5 SDK and only load there. This bundle  
will contain your NSViewController subclass and allow you to  
conditionally call -setAccessoryView: on 10.4 and - 
addAccessoryViewController: on 10.5. This is a general pattern that  
you can use when you want to provide alternate functionality where it  
is a requirement to subclass and that subclass only exists on a newer  
version of the OS.


As for -setAccessoryView: (and other deprecated methods) there really  
isn't a case of formal vs informal deprecation - deprecated is  
deprecated. In this particular case, using -setAccessoryView: for  
example will disable the inline print preview, so you'll want to avoid  
calling it on 10.5.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How to implement Quartz GL ?

2008-07-04 Thread David Duncan

On Jul 4, 2008, at 6:28 PM, David Duncan wrote:

For all windows app wide (probably your situation) add the  
"QuartzGLEnable" key to your Info.plist (with boolean value true).
For specific windows, call setPreferredBackingLocation: with the  
value NSWindowBackingLocationVideoMemory. See <> for more info.


Heh, internal links for the lose -- anyone trying to follow it, try  
this one instead: <http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/setPreferredBackingLocation: 
>

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How to implement Quartz GL ?

2008-07-04 Thread David Duncan

On Jul 4, 2008, at 10:42 AM, Mario Gajardo Tassara wrote:


Hi to all,

I am programming a sort of game purely in Quartz 2D API, but i want  
to accelerate the blitting process with Quartz GL, but i can´t find  
any information in the developer docs. Anyone with experience in  
Quartz GL can help me how to implement this in my code. Thanks in  
advance.



There are two methods you can use in a Cocoa app.

For all windows app wide (probably your situation) add the  
"QuartzGLEnable" key to your Info.plist (with boolean value true).
For specific windows, call setPreferredBackingLocation: with the value  
NSWindowBackingLocationVideoMemory. See <http://dts/pages/doc-preview.php?apple_ref=//apple_ref/occ/instm/NSWindow/setPreferredBackingLocation:&editid=3310 
> for more info.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Control USB Power

2008-06-12 Thread David Duncan

On Jun 12, 2008, at 10:38 PM, Omar Qazi wrote:

I have a Cocoa application that controls an external USB device. I  
want to be able to turn the device off when the user performs some  
action, like click a button. Is there a way in Cocoa or IOKit to  
disable power to a USB Socket? The application runs on Leopard.



Are you really sure you want to turn off the USB socket itself? It  
would seem to me that you really want to use a device that has  
software control over its power state instead and that you would just  
send the proper message to turn it on or off rather than turning off  
the USB socket. That said, I have no idea if what you are asking is  
possible...

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer scale transform

2008-06-11 Thread David Duncan

On Jun 11, 2008, at 8:56 AM, Brian Christensen wrote:

Is it expected behavior that when applying a  
CATransform3DMakeScale() transform to a CALayer the layer's current  
bitmap information is what gets scaled (using some type of filter)  
rather than asking the layer to actually redraw itself into the,  
presumably, freshly transformed context? Currently applying a scale  
transform appears to result in unacceptable pixelation.


This is expected behavior.

I can't seem to find anything in the documentation on this behavior.  
The relevant sections discuss it as "transforming a layer's  
geometry." Maybe I'm not understanding something fundamental, but I  
would have figured that a geometry transform wouldn't simply stretch  
the existing device pixel based bitmap content using minification/ 
magnification filters to fit into the newly scaled unit size (at  
least, from my understanding, this certainly isn't how a transform  
applied to the drawing context would cause regular Cocoa drawing to  
behave). I can understand this being done if the layer content is a  
bitmap image to begin with, but I certainly wouldn't expect this to  
be the case for text.



Effectively a CALayer represents a texture with the layer's contents  
on the video card. As the docs say, transforms only affect geometry.  
The texture does not include geometry, thus the current content is  
scaled rather than being re-rendered. At even moderate zoom factors  
scaling the content could cause issues with maximum texture sizes on  
the video card your running on.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: applications list on Multi monitor

2008-06-09 Thread David Duncan

On Jun 8, 2008, at 10:34 PM, Apparao Mulpuri wrote:


 In my Multi monitor application, i have to list out application
names with respect to each monitor.

Ex: Lets say Monitor 1(Primary monitor) having iTunes, AddressBook,
Calculator and TextEdit(Multi Doc) application windows and Monitor2
having TextEdit and Mail application windows.

For Monitor1, i have to get iTunes, AddressBook, Calculator, TextEdit
applications list and for Monitor2, it is  TextEdit and Mail list.

In Cocoa, is there any provision to achieve this?.



In Leopard you can use the CGWindow apis to get a list of all windows  
on the screen (see the Son Of Grab sample code) and then use  
CGGetDisplaysWithRect() to determine what displays each window is on.


--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSString vs NSPathStore2

2008-05-22 Thread David Duncan

On May 22, 2008, at 10:38 AM, [EMAIL PROTECTED] wrote:

I am then trying to populate an NSTableView with a filename obtained  
from a
NSOpenPanel. The problem is that NSOpenPanel seems to return a  
NSPathStore2
and not an NSString, which seems to be causing problems. Is there  
are a way

to convert NSPathStore2 to an NSString?



NSPathStore2 is not documented anywhere and the documentation for  
NSOpenPanel doesn't reference it. I would recommend reading the  
documentation again, as if your asking your question based on the  
output of -description on the objects returned, then you may be  
needlessly concerning yourself with an implementation detail :)

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Changing NSPrintPanel UI in 10.5

2008-05-13 Thread David Duncan

On May 13, 2008, at 1:04 PM, Rimas wrote:

If you want that functionality, then we recommend that you have a  
separate
Page Setup menu item to invoke that dialog as this is the standard  
Mac OS X

behavior and what users will expect.


Ok. I will think about that one more time. Thank you for response.
By the way, as I understand, there is no "legal" methods to get what I
want (additional button in PrintPanel). Right?



Correct, not where you wish to place it.
--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Changing NSPrintPanel UI in 10.5

2008-05-13 Thread David Duncan

On May 13, 2008, at 12:05 PM, Rimas wrote:


You are right. And that works very well. Except one thing. After
changing paper size in Print dialog I have two options - to press
Cancel (and revert changes I have made) or to press Print and save new
options + print document. I want only to change paper size and save
that information for later print. I do not want to print at this
moment. In other words, I want to have Print and Page Setup (without
printing) functionality in one (Print) dialog.



If you want that functionality, then we recommend that you have a  
separate Page Setup menu item to invoke that dialog as this is the  
standard Mac OS X behavior and what users will expect.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Changing NSPrintPanel UI in 10.5

2008-05-13 Thread David Duncan

On May 13, 2008, at 11:52 AM, Rimas wrote:


What are you trying to accomplish?

Basicaly I am trying to merge "Page setup" and "Print" dialogs. That
is easy by using NSPrintPanel's setOptions. But I want to keep "Page
setup" functionality also. I mean, I want to be able to change paper
size for example, without printing. This is quite difficult to do that
when having only "Cancel" and "Print" buttons.



This is already handled inside the existing print dialog, although not  
in its collapsed state. Clicking the disclosure button adds controls  
to allow you to select the paper size and orientation. There are other  
controls you can add (or remove) as well, search the documentation for  
NSPrintPanelOptions (used with NSPrintPanel's -setOptions: method).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Changing NSPrintPanel UI in 10.5

2008-05-13 Thread David Duncan

On May 13, 2008, at 10:23 AM, Rimas wrote:


I am interested in adding additional button to the NSPrintPanel dialog
at the very bottom line. Between ( PDF v ) and ( Cancel ). Is that
possible under Leopard?


There no simple way to do this, and I would highly discourage trying  
to do so.



Custom accessory view is not suitable for me.
Even topics from "Extending Printing Dialogs" does not help, because
they does not cover information about how to modify PrintPanel UI
outside changeable panes.


What are you trying to accomplish?


I could do this by getting NSPrintPanel window, accessing its content
view and so on... but I wanted to be sure that this is the only way to
do that. Is there any "right way" to achieve this?



There is no "right way" to do this. The content outside of any  
accessory views that you add to the print panel does not belong to you  
and should be considered an implementation detail.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Stuttering Multiple QTMovieLayers in Single Window

2008-04-30 Thread David Duncan

On Apr 30, 2008, at 12:28 AM, Greg Sutton wrote:

I have a single QTMovie with one video track playing well in a  
QTMovieLayer within a window. In fact I can have three or more of  
these windows open all playing separate videos without noticeable  
slow down. However when I add a second QTMovieLayer to a single  
window things start to fall apart. This happens whether or not the  
QTMovieLayers are in the same layer tree.


In general, one layer tree should be more performant than multiple  
layer trees in a single window, as there are fixed costs for each root  
(basically an OpenGL context and the associated machinery for getting  
it drawn correctly). That the QTMovieLayer is causing you problems  
like this is a bug that you should file.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Weird Problem With CGImage

2008-04-25 Thread David Duncan

On Apr 25, 2008, at 11:45 AM, Jean-Daniel Dupas wrote:

I didn't find any documentation about CGDataProviderCopyData()  
except this comment in the header:


/* Return a copy of the data specified by provider. Returns NULL if a
* complete copy of the data can't be obtained (for example, if the
* underlying data is too large to fit in memory). */

What is the expected output format of the data it returns ?



The output image data is the same format as the associated CGImageRef.  
You can use the CGImageGet*() functions to determine the exact format  
of the data returned.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: mask nsimage

2008-04-25 Thread David Duncan

On Apr 25, 2008, at 9:37 AM, Dominik Pich wrote:

I have an NSImage I need to draw (correctly scaled) in a pecifc  
drawRect. (got that of course)
Now whenever I draw it I want to mask it so it appears beveled,  
rounded and (to make it harder) kinda '3d-isch'

--> see an IPhoto event for what I want to doo aproximaty.


From the looks of it, it seems you would just clip to a rounded rect  
and add a shadow.


Now what technqiue should I use.. I mean CG kinda looks like it does  
what I need but I wanted to know if there wasn't an easier way :)  
(the CG APIs look 'weird' and the docs dont provide sample or pseudo  
code for _this_)



The CG API is almost 1:1 with NSBezierPath and other Cocoa Graphics  
tools, although both API do offer abilities that the other doesn't  
directly offer. As for "weird" I can't really say anything to that :).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Weird Problem With CGImage

2008-04-25 Thread David Duncan

On Apr 25, 2008, at 7:51 AM, Carter R. Harrison wrote:

This bug in my code has been driving me nuts for days, but I have  
finally isolated the issue - only problem now is I don't understand  
what I'm doing wrong.


I have a CGImage that I want to get the raw data bytes for.  My code  
is below:


CGImageRef sectionToCache =  
CGImageCreateWithImageInRect(backingStore, CGRectMake(x, y, cx, cy));
NSLog(@"CGImage to cache has dimensions %d x %d and %d bytes per  
row", CGImageGetWidth(sectionToCache),  
CGImageGetHeight(sectionToCache),  
CGImageGetBytesPerRow(sectionToCache));
CFDataRef dataRef =  
CGDataProviderCopyData(CGImageGetDataProvider(sectionToCache));

NSLog(@"Length of cachedImage data: %d", CFDataGetLength(dataRef));

When the code runs, the log spits out the following:

CGImage to cache has dimensions 417 x 234 and 1668 bytes per row
Length of cachedImage data: 6672

What is killing me here is that the CGImage has dimensions 417x234  
and 1668 bytes per row.  That to me means that the CFDataRef that I  
am obtaining should be 390,312 bytes (234 x 1668).  But the  
CFDataRef is only 6,672 bytes which is nowhere close to what I think  
I should be getting.  So I must be doing something wrong in trying  
to get the bitmap data, but I'm not sure what else to do and I even  
found some Apple docs with an example doing the exact same thing  
that I am doing.  Can anybody provide some insight on this?  Thanks  
everybody.


This seems to be related to the CGImageCreateWithImageInRect() call,  
but I can't imagine why. CGDataProviderCopyData() seems to work  
perfectly with an original image in my limited testing, so please file  
a bug (and let me know what the bug number is).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: QTMovie grabing while playback

2008-04-24 Thread David Duncan

On Apr 24, 2008, at 4:03 PM, Uli Kusterer wrote:

4) I think there's a sample on Apple's web site somewhere that draws  
pushbuttons etc. on top of a movie (or maybe it was an OpenGL  
scene?). Anyway, that approach might work for your movie, too.



The sample that does this uses Core Animation to do the layering,  
which of course will result in text that does not use sub-pixel  
antialiasing (which I presume is why you said not to use a CALayer).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Problems with [NSArray count]

2008-04-22 Thread David Duncan

On Apr 22, 2008, at 2:45 PM, Peter Browne wrote:


The process followed is:

1) the myController object acquires data from a text file, using  
NSString's -stringWithContentsOfFile:encoding:error
2) myArray then grabs this data (a bunch of numbers) using NSArray's  
-componentsSeparatedByString:
3) myController then passes the myArray object to myView (for later  
graph drawing) using my - (void)displayData:(NSArray *)theArray method

4) myView then calls [theArray count]
5) EXC_BAD_ACCESS

inserting a [myArray retain] just before passing the data to the  
view fixed the problem. Why should this be the case?
As far as I'm aware the object isn't being released at that point,  
so what's the need for a -retain message?



First, read this: <http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html 
>


Once you have, you will note that the array returned by - 
componentsSeparatedByString: doesn't belong to you unless you retain  
it. You are likely getting your bad access because the autorelease  
pool is being drained in between your call to -displayData and -count  
(and -displayData: probably should be named -setDisplayData: instead).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Problems with [NSArray count]

2008-04-22 Thread David Duncan

On Apr 22, 2008, at 2:03 PM, Peter Browne wrote:

I'm returning to Cocoa after quite a long break, and it seems that  
I'm a little rusty...


All I want to do is find out the number of items in an NSArray and  
store that as a variable, which I can then find the square root of.


The docs tell me that [NSArray count] returns an NSUInteger, but  
exactly WHAT one of these is, or how I use it is baffling me.


An NSUInteger is just an integer that is 32-bits or 64-bits depending  
on if your application is compiled for 32-bit or 64-bit.



a simple

int i = [myArray count];

crashes out, and I've tried various other types of variable to no  
avail. Any thoughts? Am I missing something blindingly obvious here?



Are you getting an exception? perhaps myArray isn't really an NSArray  
at the time that you are sending it the -count message?

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: thread count problem

2008-04-21 Thread David Duncan

On Apr 21, 2008, at 1:03 PM, Nick Rogers wrote:

when I run my cocoa app, Activity monitor shows it having 2 threads,  
and thats ok, cause I'm running one POSIX thread with the start of  
the app and which remains till the app is exited.
The problem is when I detach a new NSThread, from which I'm calling  
"performSelectorOnMainThread:" frequently, the thread count goes to  
4. and when this new NSThread finishes, the thread count comes to 3  
and not 2. And it stays 3.


Is there something wrong?


Does this cause problems for your application? Mac OS X will spawn  
threads on behalf of your application to perform certain activities  
and this is generally beyond your control. This should typically be  
completely transparent to you.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: drawRect: called twice for NSView subclass.

2008-04-20 Thread David Duncan

On Apr 19, 2008, at 5:15 PM, William Hunt wrote:

Essentially I have a window with a custom view atop a button.  What  
happens at each refresh, however, is that the custom view's  
drawRect: is called twice.  First it is called with the whole  
window's NSRect, then it is called with the "proper" NSRect.  The  
result is that if I draw a circle at (0,0), it gets drawn twice at  
different locations:


What is going on here?  Is this buggy behavior or correct behavior?   
My code is basically a new Cocoa application with a single NSView  
subclass.  There is absolutely nothing funny (that I know of) going  
on here.  That leads me to believe that the behavior is "correct,"  
and that I'm just missing something.


For the record, I only want the one call to drawRect:, the one with  
the "proper" NSRect.



FYI, the "proper" rect is not guaranteed to be the bounds rect of your  
view either. If Cocoa only needs you to refresh a subsection of your  
view, then you will get a -drawRect: with just that subsection. In  
general, you should only use the rect passed to you in -drawRect: as a  
guideline for what needs to be updated (i.e. for rejection tests)  
rather than to define the coordinate system to draw into.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Core Animation/Layers and Borderless Windows

2008-04-17 Thread David Duncan

On Apr 16, 2008, at 6:49 PM, Karl Goiser wrote:

I'm creating a borderless window whose content view uses Core  
Animation...


When I do this, the window is drawn without any shadow no matter the  
alpha of the content.


- a borderless window with a normal view draws the window's shadow.

- a normal window with a content view which uses core animation  
shows the window's shadow (for example, the Recipes example).  This  
is probably because it is opaque.


If I set the borderless window to opaque, a shadow is drawn.   
However, I want the window to be transparent - and have a shadow  
just like can be done with a normal view.


Is there something I need to do to get the desired behaviour?



When all of your window contents are drawing via Core Animation (which  
seems to be the case here) there is nothing for the Window Server to  
use to calculate the shadow (the window is completely empty, hence no  
shadow). You can draw something minimally to the window to give it  
something to "grab onto" when calculating the shadow.


I'm going to go out on a limb and guess you want click-through on the  
parts that remain transparent as well? You will soon find that isn't  
possible either...

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: EXC_BAD_ACCESS when calling CGContextDrawLayerInRect

2008-04-14 Thread David Duncan

On Apr 14, 2008, at 12:46 PM, Carter R. Harrison wrote:


I'm getting the reference to the context by using:

CGContextRef context = [[NSGraphicsContext currentContext]  
graphicsPort];


in my view's initWithFrame: method.


Which isn't guaranteed to be anything in particular (and could in fact  
be NULL).


Based upon what you said, how would you recommend I draw to a  
CGLayer prior to the first invocation of drawRect: (at which point I  
could initialize a CGContextRef instance variable)?



You can't practically. All you can do is wait for your first - 
drawRect:, detect that you haven't created the CGLayer and do so (and  
draw to the layer) and then proceed as normal.


Now, if you really just want to record some drawing that you use over  
and over and over again, then you can just draw to a bitmap context  
and grab an image of that context to draw. It should have very similar  
performance characteristics for drawing, but will be easier for the  
system to manage (since an image is immutable).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: EXC_BAD_ACCESS when calling CGContextDrawLayerInRect

2008-04-14 Thread David Duncan

On Apr 14, 2008, at 11:56 AM, Carter R. Harrison wrote:

cgback is a CGLayerRef instance variable that I setup when the view  
is inited.  I use the following line:


cgback = CGLayerCreateWithContext(context, CGSizeMake([self  
bounds].size.width, [self bounds].size.height), NULL);


It's my understanding that I do not need to retain cgback with  
CFRetain(), but I do need to release cgback in my dealloc() method -  
which I'm doing.



Where is "context" coming from? CGLayers are made relative to an  
example context that they optimize themselves for, but at -init your  
view hasn't been drawn yet, so there is no context. I suspect that  
your getting something you very much do not expect.


In general if you want to use layers with views, you should create the  
layer on the first -drawRect: call rather than trying to have them  
around from -init forward.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Basic Core Animation question

2008-04-14 Thread David Duncan

On Apr 13, 2008, at 12:01 AM, Greg Sabo wrote:

Ah! It compiled. Thank you very much! And thanks to Michael for  
putting

together the sample project.

Now to get the CALayer to draw a path. Most of the documentation  
I've seen
suggest to do this with a delegate function, is that correct? Here  
is the

delegate function I've written (a.k.a. copied from another program):

// 


- (void)drawLayer:(CALayer *)theLayer
   inContext:(CGContextRef)theContext {
   CGMutablePathRef thePath = CGPathCreateMutable();

   CGPathMoveToPoint(thePath,NULL,15.0f,15.f);
   CGPathAddCurveToPoint(thePath,
 NULL,
 15.f,250.0f,
 295.0f,250.0f,
 295.0f,15.0f);

   CGContextBeginPath(theContext);
   CGContextAddPath(theContext, thePath );

   CGContextSetLineWidth(theContext, 1);

CGContextSetRGBStrokeColor(theContext,0.0,0.0,1.0,1.0);


   CGContextStrokePath(theContext);
}
//**

I'm just seeing the black background right now.
Again, thanks for your help and sorry I'm such a pain :)


Note that this code (by itself) leaks, the mutable path your creating  
is never released (in this snippet). You actually don't need to do  
this anyway, you can use CGContextMoveToPoint/CGContextAddCurveToPoint/ 
etc instead and not have to worry about the memory management issue  
that using CGPath brings up.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSCompositeSourceOver equivalent in Quartz 2D?

2008-04-14 Thread David Duncan

On Apr 13, 2008, at 1:43 PM, Carter R. Harrison wrote:

I'm trying to do some drawing in Quartz 2D.  I'm trying to set the  
blending mode of my CGContextRef to the equivalent of  
NSCompositeSourceOver from NSGraphicsContext.  It doesn't look like  
there is such a blending mode for a CGContext.  Am I mistaken in  
this, or is there another way of accomplishing this?  It seems funny  
to me that this blending mode doesn't exist in Quartz given that  
NSGraphicsContext should be a wrapper class around CGContextRef.



NSCompositeSourceOver is equivalent to kCGBlendModeNormal (which is  
the default blend mode in a CGContext).

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Efficient object wrappers and GC

2008-04-11 Thread David Duncan

On Apr 11, 2008, at 10:25 AM, Buddy Kurz wrote:

I'm wondering if it would make sense (or be possible)  to override - 
retain and -release to increment/decrement your own variable in  
addition to using the inherited behavior.  In the GC environment,  
the inherited retain does nothing but in either environment your  
enumerator can detect the retain by checking your variable.



It isn't that the inherited retain(release/retainCount/autorelease) do  
nothing, its that they are no-op'd. They are neutered at the the level  
of message dispatcher which means that under GC your class will  
*never* see these messages.


See <http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcDesignPatterns.html 
>

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Replacement for GetApplicationEventTarget?

2008-04-10 Thread David Duncan

On Apr 10, 2008, at 12:21 PM, Michael Vannorsdel wrote:

Is there a replacement function for GetApplicationEventTarget?  I'm  
looking for one since this is the only thing I have left that's not  
64 bit compatible.


You will have to elaborate on what you are using it for, as there are  
many possible replacements.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Tips to deploy applications to multiple Mac OS X versions

2008-04-09 Thread David Duncan

On Apr 9, 2008, at 7:43 AM, Lorenzo Bevilacqua wrote:

I'm trying to build a Cocoa application so that it can run on Mac OS  
X from version 10.3.9 to 10.5.
I have 10.5 installed so the application runs fine on my system and  
on other Leopard systems.
I haven't build a project for multiple platforms yet, so I tried to  
duplicate the main Xcode target and set different deployment target  
settings like


Typically you would only use 1 target. Use the SDK to the OS whose API  
your are targeting (such as the 10.5 SDK). Then set the deployment  
target to the minimum version you wish to run on (example, 10.3).  
Finally, you would do runtime checks for API availability.


Till now all Ok, but when I try to compile for example the Tiger  
target I get some errors (mainly about fast enumeration). Thus I  
have some questions:


- Does the Objective-C 2.0 fast enumeration make sense to be used? I  
mean, if I don't use it, will my application perform worse on Leopard?


Fast enumeration relies on selectors that are only implemented on  
10.5, so you can't use it on 10.4 or earlier systems. You cant use  
most Obj-C 2.0 features if you wish to be compatible with 10.4 or below.


- Is there a way to differentiate part of code by platform? I  
remember I saw in some files lines like this


#if MACOSX_DEPLOYMENT_TARGET == MAC_OS_X_VERSION_10_4
#endif

is this correct?



This is a compile time check. Generally it is appropriate if you plan  
to ship a binary with a specific compile-time dependency. It sounds  
like you really want a run time check, which requires you to check for  
the availability of the features you are trying to use. How you check  
for this will depend on what you are doing to some degree.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: ImageIO key properties

2008-04-07 Thread David Duncan

On Apr 7, 2008, at 12:46 PM, Mirko Viviani wrote:

I've tried linking with -framework and -weak_framework with the same  
results.
kCGImagePropertyDNGDictionary and others properties declared in  
CGImageProperties.h are not defined in the framework.

Is it a bug or am I missing something?



You shouldn't need to specify the actual link parameters, just set the  
SDK (to 10.5) and the deployment target (to 10.4) and Xcode should  
figure everything out for you.


That said, this does look suspicious since the framework didn't  
declare kCGImagePropertyDNGDictionary until 10.5 but there is no  
availability macro attached to it. You should file a bug.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: ImageIO key properties

2008-04-07 Thread David Duncan

On Apr 6, 2008, at 11:22 PM, Mirko Viviani wrote:

for an application targeted for 10.4 I need to access the value of  
some key properties defined
for 10.5 in CGImageProperties.h, like  
kCGImagePropertyExifAuxDictionary.


Is there a legal way to do this?



Assuming you have your project set properly, standard weak-linking  
policies should apply. See the Frameworks Programming Guide on  
Frameworks and Weak Linking at <http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html 
>

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: -[CALayer setContents: cvPixelBufferRef ] ?

2008-04-03 Thread David Duncan

On Apr 3, 2008, at 1:00 PM, Jonathan del Strother wrote:

I'm using the QTCapture api to record from a camera, while displaying
a live preview (ideally with 0 lag) in Core Animation.



The QTCaptureLayer doesn't do what you want?
--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: -[CALayer setContents: cvPixelBufferRef ] ?

2008-04-03 Thread David Duncan

On Apr 3, 2008, at 12:28 PM, Jonathan del Strother wrote:
If you have a CVPixelBufferRef, you can use the various functions  
defined
for a CVPixelBuffer to access the base address, row bytes, width,  
height and

other attributes to create a CGImageRef directly from it via
CGImageCreate().


Even for yuv?  I thought CGImageCreate only handled variations on
rgba, but will give it another go...



Your right, I forgot that detail :). I'm not familiar but Quicktime  
might be able to convert it for you before you get it (which is likely  
the best thing in this case).


But that brings up the question of what are you trying to do? :)
--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: -[CALayer setContents: cvPixelBufferRef ] ?

2008-04-03 Thread David Duncan

On Apr 3, 2008, at 11:34 AM, Jonathan del Strother wrote:


CALayer says that 'contents' is "typically a CGImageRef, but may be
something else".  I (optimistically) tried assigning the
CVPixelBufferRef directly to the contents, but apparently that's not
included in the mysterious 'something else' list.


Could you point out where it says that? Typically you would set the  
contents property either as a CGImageRef, or as the value of the  
contents of another layer (which would cause them to share contents).



The only way I've found of going from CVPixelBufferRef to CGImageRef
is via CIImage, something like the following :



If you have a CVPixelBufferRef, you can use the various functions  
defined for a CVPixelBuffer to access the base address, row bytes,  
width, height and other attributes to create a CGImageRef directly  
from it via CGImageCreate(). You should be able to find more  
information by consulting the CoreVideo and Quartz references.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 1 pixel bordered CALayer renders improperly

2008-04-03 Thread David Duncan

On Apr 2, 2008, at 10:26 PM, Martin wrote:

It seems that a CALayer with a borderWidth of 1.0 renders  
improperly: all the border's pixels are good except the very top  
right pixel which has a different colour.


Example: http://img34.picoodle.com/img/img34/4/4/2/f_CALayerm_6e43e20.png

Is this a know bug? Is there a workaround?



Haven't seen it before, please file it with a reproducible case. Best  
idea for a work around would be to draw the border yourself (either  
override -drawInContext or set a delegate and override - 
drawLayer:inContext) but I have no idea if that would work.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Convert kernel AbsoluteTime to a NSDate

2008-03-25 Thread David Duncan

On Mar 25, 2008, at 2:32 AM, Matt Burnett wrote:


I really need to get it in to a NSDate.


The big question here is Why? Without understanding what you want to  
do, it is unlikely that anyone will be able to help you.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSString may not respond....

2008-03-19 Thread David Duncan

On Mar 19, 2008, at 10:10 AM, J. Todd Slack wrote:

Continuing my quest to get back into Cocoa/Objective-C, I am getting  
the
following error stating that NSString may not respond to certain  
calls.


Here is a screenshot:

http://jasonslack.biz/pic3.png

Can anyone explain what I am doing wrong because as far as I can see  
this

should be valid?



You might want to just copy and paste the code & errors into the  
message rather than a screen shot, especially since your image may go  
away while the message stays in the archives :).


That said, what SDK are you targeting? Both of these messages were  
added in 10.4, so if your targeting the 10.3.9 SDK then that might be  
why your getting these warnings.

--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


<    5   6   7   8   9   10   11   >