advertisement

Article:
  Working With Bitmap Images; Document-Based Application Redux
Subject:   Some changes
Date:   2002-04-27 17:00:43
From:   michele
I've made some changes to avoid warnings at compile time, improve image scaling, and avoid memory leaks.


I - To avoid warning at compile time:


1 - Warning: IAWindoController does not respond to scaleImageTo


Added in IAWindowController.h the declaration of:


- (void)scaleImageTo:(float)_scale;



2 - Warnings: cannot find method
return type for 'activeImage' defaults to id


Added in IAWindowController.m:


#import "MyDocument.h"



II - To avoid incorrect redrawing of image when scaling (image drawn over scrollers)


1 - Change in (void) scaleFrameBy: (float) scale in IAImageView.m


Replace: [self setNeedsDisplay: YES];
by: [[[self window] contentView] displayIfNeededIgnoringOpacity];


As the scrollers are opaque, we need to force a complete redraw.


2 - Add in (void) validateScrollers in IAImageView.m


at the very end: [scrollView tile];


Forces a redraw of scrollView, clipView, scrollers, and ImageView taking into account the opacity (does not redraw the opaque parts).



III - To avoid memory leaks


1 - Add


[windowController release];


at the end of - (void)makeWindowControllers in MyDocumemt.h


2 - Change - (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) aType in MyDocument.h


- (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) aType
{
activeImage = [[[NSImage alloc] initWithData: data] autorelease];
return (activeImage != nil);
}


1 to 2 of 2
  1. Some changes
    2002-07-14 12:04:04  blukens [View]

  2. Some changes
    2002-05-02 09:24:31  psheldon [View]

    • Some changes
      2002-05-03 12:10:48  michele [View]

      • Some changes
        2002-05-04 09:15:00  psheldon [View]

        • Some changes
          2002-05-06 13:35:01  michele [View]

          • I am Paul, Sherlock 3 of Jaguar multithreaded
            2002-05-07 22:37:00  psheldon [View]

            • I am Paul, Sherlock 3 of Jaguar multithreaded
              2003-06-10 16:36:20  anonymous2 [View]

            • I am Paul, Sherlock 3 of Jaguar multithreaded
              2002-05-13 03:59:57  michele [View]

1 to 2 of 2