Saving image output to file in cocoa app

Discussion in 'Mac Programming' started by FelixMC, Jan 30, 2008.

  1. FelixMC
    Expand Collapse
    macrumors member

    Joined:
    Jan 4, 2008
    #1
    Ok, so I'm more of a Html/Javascript/CSS/PHP/Ruby/Applescript kind of person, and I really stink at Java, Cocoa and Objective-C...:D
    But I'm attempting to get better, so I'm occasionally building an app here and there to help clean up my Mac or just solve problems I can't with other apps:p..
    Right now to make my web developing life easier, I'm "trying" to build a nav bar generator, which generates both code and graphics. I went ahead and build all my application "engine" and code and graphics generators in Quartz Composer. Turns out it's a great tool for making "rules", besides just cool graphics. So, the application as it is now, works pretty well, with the few exceptions of a few bugs here and there, and of course I could add a slicker interface to it.
    Now heres my problem. The app generates different graphics, according to some user controlled inputs and settings. There is a NSImageView object(¿?) binded to a image output from a QC patch controller. I would like the user to be able to save the image to a usable image file, preferably in .png format, but any other format supporting an alpha channel and recognized by popular browsers without need of an external plug-in I think will do. :)
    So, what's the easiest way to do this..? I'll take anything you guys have to offer including alternatives or links or wtv :D
    BTW, if this helps, I'm running Tiger, and I'm using the Tiger SDK and Xcode 2.5. Thanks in advance :D
     
  2. robbieduncan
    Expand Collapse
    Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
  3. FelixMC
    Expand Collapse
    thread starter macrumors member

    Joined:
    Jan 4, 2008
    #3
    Thanks for the help &link :)
    It all makes sense, to a certain extent..:rolleyes:
    See, part of the fact that I stink at Cocoa and Objective-C, is because I never really got to really learn them. I just improvised on some things I learned from guides and tutorials..
    So, according to that link I need (or I think I do) a NSImage, a NSImage header and ".m" (¿?) file. So I initiated a NSImage (took me a while to figure that out:p). Than I created the header and ".m" file in Xcode and added the code in the header file:
    Code:
    (NSData *)TIFFRepresentation
    Now I suppose I should be linking he QC image output to the NSImage somehow..? Or the NSImageView to the NSImage..?
    And how to I retrieve the response from the NSData? I wasn't able to find an NSData class in Interface Builder. Will I need to initiate a Controller?
    Any further help, dummy slaps or links to little yellow books entitled "Cocoa for Dummies" would be greatly appreciated..:D
     
  4. robbieduncan
    Expand Collapse
    Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    If you post the project (without the compiled bits) we might be able to help. At this stage I'm struggling to understand what you've done...
     
  5. FelixMC
    Expand Collapse
    thread starter macrumors member

    Joined:
    Jan 4, 2008
    #5
    Bit of a problem...

    Ok, I will strip off all unnecessary things from the Xcode project for the sake of saving space and put it on here... but I've got a little problem....
    Here it is...
     

Share This Page