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

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSImage handling...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage handling...


  • Subject: Re: NSImage handling...
  • From: Martin-Luc Girard <email@hidden>
  • Date: Wed, 29 Oct 2003 16:47:23 -0500

Hi!

So you're saying that runEvents, when called multiple times (by repeatedly pushing a button or whatever), always reverts to the original prior to processing, right? I assume your iterations within the method work...

Now I'm far from being an expert in Cocoa just yet, but it seems to me that you're copying [[self document] activeImage] into 'image', and then working from that local copy, never saving the changes back to the original. So every time the method is called, it copies [[self document] activeImage] AGAIN, and performs the transformations on that.
You'd need to write the changes back into [self document] so that it returns the new image the next time activeImage is called...

Hope this helps!

ML

On 29-Oct-03, at 3:00 PM, Geoffrey H Wathen wrote:

Code snippets:

My application is a Cocoa document based application. It has a custom NSWindowController subclass. In that controller .m file, I have the code:

- (IBAction)runEvents:(id)sender
{
int index, numEvents;
NSImage *image=[[self document] activeImage];
GRCrystal *growth=[[GRCrystal alloc] init];

numEvents=[totalEvents intValue];
[view setImage:image];

for ( index = 0; index < numEvents; index++)
{
image=[[growth Grow:image] retain];
}
[view setImage:image];
[growth release];

}

runEvents is keyed off of a button and a text field in the window. totalEvents is a text field. GRCrystal is a custom class containing the method Grow which simply goes through the NSImageRep of the NSImage that's passed to it, pixel by pixel, and makes certain random changes. Then it returns the modified NSImage. However, when it's called again, it clearly starts from the original loaded image when making its modifications. Is this enough, or would more code help?

On Tuesday, October 28, 2003, at 08:59 PM, Greg Hulands wrote:

Providing some code snippets would help diagnose the problem. even pseudo code.

On 29/10/2003, at 11:49 AM, Geoffrey H Wathen wrote:

Hi everyone,
I've got a peculiar problem. Clearly, I'm not understanding something. I have an application that is making modifications to an NSImage object, using a repetitive method. The problem I've come up against is that every time I repeat the method, it reverts to the original form of the image, not preserving the changes that were made the previous time the method was run. Does anyone have any ideas?

Geoff.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSImage handling... (From: Geoffrey H Wathen <email@hidden>)

  • Prev by Date: Re: how to move files to trash?
  • Next by Date: Re: DVD playback format?
  • Previous by thread: Re: NSImage handling...
  • Next by thread: Using bundled tool in Xcode
  • Index(es):
    • Date
    • Thread