Note that there are some explanatory texts on larger screens.

plurals
  1. POMac Dev - Image I/O
    primarykey
    data
    text
    <p>my first question here.</p> <p>I am trying to create a simple application which takes in a picture from one location, and places it to the desktop. The problem I'm having is this error:</p> <pre><code>2012-10-27 10:49:16.405 saveFile[3271:303] +[__NSCFConstantString scheme]: unrecognized selector sent to class 0x7fff73c01e38 2012-10-27 10:49:16.406 saveFile[3271:303] +[__NSCFConstantString scheme]: unrecognized selector sent to class 0x7fff73c01e38 </code></pre> <p>On this line:</p> <pre><code>CGImageRef imageItself = CGImageSourceCreateImageAtIndex(myImageSource, 0, NULL); </code></pre> <p>And here's the actual code:</p> <p>Header file:</p> <pre><code>#import &lt;Cocoa/Cocoa.h&gt; //NSOpenPanel = use finder NSOpenPanel *openPanel; //URL is the directory NSURL* theDoc; //Don't allow bottom button to malfunction by being clicked early. bool topButtonClicked = NO; @interface saveFileAppDelegate : NSObject &lt;NSApplicationDelegate&gt; - (IBAction)moveFile:(id)sender; - (IBAction)chooseFile:(id)sender; @property (nonatomic, retain) IBOutlet NSTextField *label; @property (assign) IBOutlet NSWindow *window; @end </code></pre> <p>.m file:</p> <pre><code>#import "saveFileAppDelegate.h" @implementation saveFileAppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application } - (IBAction)chooseFile:(id)sender { openPanel = [NSOpenPanel openPanel]; [openPanel beginWithCompletionHandler:^(NSInteger result){ if (result == NSFileHandlingPanelOKButton) { theDoc = [[openPanel URLs] objectAtIndex:0]; [_label setStringValue:[NSString stringWithFormat:@"%@",theDoc]]; // Open the document. topButtonClicked = YES; } } ]; } - (IBAction)moveFile:(id)sender { if (topButtonClicked == YES) { //Take in picture CGImageSourceRef myImageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)(theDoc), NULL); //CGImageRef myImage = CGImageSourceCreateImageAtIndex(myImageSource,0,NULL); //Save picture to desktop //Save where I wish to save the file CFURLRef desktopURL = (CFURLRef)@"/Users/Ken/Desktop/"; //Save where I want to save, the type of file I expect to save, number of images to save, any additional options. CGImageDestinationRef whereToSave = CGImageDestinationCreateWithURL(desktopURL, kUTTypeJPEG, 1, NULL); //Create a reference to the image itself, take in the image read, which image (only one, so 0), and additional options. CGImageRef imageItself = CGImageSourceCreateImageAtIndex(myImageSource, 0, NULL); //Begin final preperations, pull altogether desktop URL, the image read in before, and additional options. CGImageDestinationAddImage (whereToSave, imageItself, NULL); //Finalize (write the file) CGImageDestinationFinalize(whereToSave); //CGImageDestinationRef saveImageToDesktop (CFURLRef desktop, CFStringRef jpeg, size_t count, CFDictionaryRef NULL); } else{ /* open an alert with an OK button */ NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText:@"Stop it."]; [alert runModal]; } } void CGImageDestinationAddImage (CGImageDestinationRef idst, CGImageRef image, CFDictionaryRef properties); @end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload