Skip navigation.
 
mlImageNamed not refreshing
FROM : Joe Zobkiw
DATE : Mon Sep 30 17:44:00 2002

Hello All,

I am having a little problem getting an NSImageView to "reset" its image
once I've altered it. Here is what I'm doing (pseudo code):

    // Set the image in awakeFromNib
    // This works!

    NSImage *theImage = [NSImage imageNamed:@"picture.tiff"];
    [m_imageView setImage:theImage];
    [m_imageView setNeedsDisplay:YES];

    // Later on I alter the image in another method calling it like this:
    // This works!

    [m_imageView setImage:[thePlugin doImageEditing:[m_imageView image]]];
    [m_imageView setNeedsDisplay:YES];

    - (NSImage*)doImageEditing:(NSImage*)theImage
    {
        NSRect theRect;
        theRect.origin.x = theRect.origin.y = 0;
        theRect.size = [theImage size];
        [theImage lockFocus];
        [[[NSColor lightGrayColor] colorWithAlphaComponent:0.1] set];
        NSRectFillUsingOperation(theRect, NSCompositeSourceOver);
        [theImage unlockFocus];
        return theImage;
    }

    // The problem is, when I re-execute the first three lines,
    // the image never "resets" - shouldn't this reload the image
    // from the resource? I tried setting the image cache to
    // NSImageCacheNever but that doesn't seem to make a difference.

    NSImage *theImage = [NSImage imageNamed:@"picture.tiff"];
    [m_imageView setImage:theImage];
    [m_imageView setNeedsDisplay:YES];

Any thoughts?

--
Joe Zobkiw
TripleSoft Inc.
<email_removed>
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlImageNamed not refreshing Joe Zobkiw Sep 30, 17:44
mlRe: ImageNamed not refreshing Joe Zobkiw Sep 30, 18:56
mlRe: ImageNamed not refreshing Brock Brandenberg Sep 30, 23:45
mlRe: ImageNamed not refreshing Joe Zobkiw Oct 1, 14:30
mlRe: ImageNamed not refreshing John C. Randolph Oct 3, 20:48