Help with Macintosh programming

macintosh programming, mac programming, mac os programming, mac os x programming, mac programming language, mac programing

Archive for April, 2012

Getting at specific pixels in an image

I’m currently working on an application that loads an image and is supposed
to run the image through a filter in order to make a new image. I am able to
get the original image to show itself via openGL, but I don’t know how to
access individual pixels. I need to get the rgb values (or hue or however
the colors are stored) so I can alter them and use them to build a new
image. I’ve looked through the NSImage class, but I couldn’t find what I
needed there.

Any pointers? Is there any sample code somewhere that shows how I could do
this?

C Lund, Oslo
http://www.notam02.no/~clund/

.
posted by admin in Uncategorized and have Comments (13)

Application with Quicktime

I have trying to figure out the best method to include Quicktime image and
movie decoding into my application.
I’m trying to find the best method to decode a sequence of image files,
without tying up the main thread and therefore the GUI. I know that the
documentation says that Quicktime cannot be used in a thread because it is
non-reentrant, but could I avoid this problem using Critical Sections in an
MP thread?
Does anybody know a way to decode images (i.e. Into a gworld) and movies,
without tying up the GUI.
Can I use Quicktime in a MP thread with critical sections?

Any help would be useful.
Thanks

Tim

posted by admin in Uncategorized and have Comments (4)

Newbie question: How to show/hide controls in Cocoa?

Hi All:

If I have a slider that I optionally want to show or hide (not dim), can I do
this in Cocoa. I want to have an array of 4 sliders and possibly only show the
first two. Can I easily make the third and fourth visible/invisible without
deleting them?

Thanks.

posted by admin in Uncategorized and have Comments (2)

adding icons for document files

I’m using Project Builder on MacOSX 10.2.x to create a Cocoa app.

I’m trying to add a custom icon for a type of data file my program will
be creating.  I filled out all the fields in the "Data Types" pane: I
added a known-good .icns file that contains the icons, set the extension
to "wset", set the role to "Editor," and set the OS type to WSET (I’m
just guessing here), all other fields blank.

So then I have my program create a test.wset file.  In Finder it is
displayed with the usual blank "I don’t know what it is" icon and the
"Kind" field says "Document," i.e., "I don’t know what it is."  However
using Finder’s "Open With" command shows my app as the only one listed
that knows how to open that type of file, so it looks like at least some
of what I did "took".  But the file’s icon doesn’t show up, and I have
no idea how I’d change the text displayed in the "Kind" field.

On BeOS I’d have to register my new document type with the FileTypes
database, which involves calling OS API functions.  Do I have to do
something similar in MacOSX?

Do I have to call some API function when I create .wset files to
indicate that they are one of mine?  Something other than just giving
them the .wset extension?  Again, that’s what I’d have to do on BeOS.

Are there any example projects that do this that I could look at?

posted by admin in Uncategorized and have No Comments

thread_policy_set() fails – why?

Hi,

I create a pthread which works but when calling thread_policy_set()
afterwards, it fails.

pthread_t theThreadId;

 if(pthread_create(&theThreadId, NULL, mypthreadEntry, this) != 0)
  {
    // some error
  }

    kern_return_t error;
    thread_precedence_policy_data_t precedencePolicy;

    precedencePolicy.importance = 6;     // or some other value
    kern_return_t error = thread_policy_set((unsigned int)theThreadId,
THREAD_PRECEDENCE_POLICY, (thread_policy_t )&precedencePolicy,
THREAD_PRECEDENCE_POLICY_COUNT);

 if (error != KERN_SUCCESS)
     {
    // fails here
     }

Any help appreciated

Rolf


Thanks

posted by admin in Uncategorized and have Comment (1)

Calling Mach-o callback from CFM code

Apple developer site has a sample code showing how to call CFM
function from Mach-o code
(http://developer.apple.com/samplecode/Sample_Code/Runtime_Architectur…).

The sample has some glue code the turns a CFM function pointer into
Mach-o function pointer.

I did not find any example showing how to the the opposite – call
Mach-o function from CFM code.

I have Mach-o code that passes a callback to CFM code, when the CFM
calls this function pointer it crashes. The thing is that I cannot
change the CFM code, so if some glue code could be applied before
passing the function pointer to the CFM cod, the callback will be
called properly.

Does any one know of such glue code?

Shai Shasag

posted by admin in Uncategorized and have Comments (3)

Re: Apple Dev' Tools, Please help…

In article <bc18f623.0303010622.6a44f…@posting.google.com>,

 james.fos…@mac.com (James) wrote:
> I know this is an Obj-C group, but Cocoa counts and I have a small
> problem.

Cocoa *doesn’t* count, unless you have a question about Obj-C. This is
not a question about Obj-C, it’s a question about Cocoa’s dev tools, and
so it doesn’t really belong here. I’ve crossposed this reply to
comp.sys.mac.programmer.help and set followups accordingly, hopefully
somebody can help you out there.

- — -

> When I create a new project in Project Builder (Dec 2002)
> that has a space in the name, for example My Application, it won’t
> compile telling me that it couldn’t find the first part of the name,
> eg. My. It also makes a file called MyApplication_Prefix.h. When I try
> to compile the project it displays ‘Missing file or Directory:
> Application_Prefix.h’ How can I stop this from happening, it works OK
> without the space, but I need it for most of my App’s.

> Any help would be greatly appreciated.

> Sorry this isn’t strictly Obj-C. Thanks!

posted by admin in Uncategorized and have Comment (1)

Unhandeled File Type dialog OS X IE

Hi,

When clicking on a web page link that points to a downloadable file
that has a MIME type that is not listed in the helper applications, IE
popup the Unhandeled File Type dialog box asking what to do with the
file.
The options are: Save As, Cancel, Pplugin and Application. If you
click "Application" it would show a file picker that lets you choose
the application.
My problem is that my application is grayed out in that dialog, that
is, it seems un selectable although it’s a valid packaged application.
Intersting enough, if I want to add my application as a helper app to
the IE preferences dialog /helper applications and I hit the "Browse"
button there to select an application, my application would show
selectable and I can select it without a problem.

Any idea why I can’t select my app on the Unhandeled File Type dialog?
anything needs to be done in the resources or property list to enable
this? or may it’s yet another MS bug…

Thanks
 Pini

posted by admin in Uncategorized and have No Comments

NSTextField and mouseDown event ?

Hi,

is it possible to connect a NSTextField to the mouseDown event ?

The NSTextField is not editable and the text is not selectable
(in IB under Info/Attributes/Options), by clicking on the
text field, the event is to be fired !?

Any hints ? Samples are very helpful !

Thx
Chris

posted by admin in Uncategorized and have No Comments

can't compile driver.

   I am having a problem trying to compile a driver in Jaguar.  I am
running 10.2.4 with DevTools Dec2002.  Can other people see if they can
compilethis driver.

cvs -z3 -d:pserver: XX…@anoncvs.opensource.apple.com :/cvs/Darwin co
Apple3Com3C90x

  When I try and compile it, I get an internal compiler error.

Thanks,
Greg

posted by admin in Uncategorized and have No Comments