• 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
Image (or view ?) not scaling with window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Image (or view ?) not scaling with window


  • Subject: Image (or view ?) not scaling with window
  • From: vinai <email@hidden>
  • Date: Wed, 3 Jun 2009 06:45:54 -0700 (PDT)

Hi Folks,

I've run into a case where an image I am creating does not scale with its parent window.  Some background - I am trying to create and application to process data stored within a file - much like any image data with a header.  However, I am not opening anything with a standard image format.

I have a selector panel than selected the kind of data I am reading, and lets me select the file.  Based on the header information in that file, I create a window, view, image, image representation with the appropriate parameters, and I can already create the window and draw the contents of my file to it.  It does this initial drawing properly.

The problem is, when I grab the edge of the window to resize it, the image that's drawn to it does not reisze with the parent window.  It maintains its original size, and stays centered in the window view.

My initialization code for the GUI elements of that window is below.  Is there a flag I am missing somewhere in this, or do I need to handle view and image resize updates in another routine ?

Thanks all.

vinai

----------------------------------------------------------------------
    NSRect tempRect = NSMakeRect (90.0, 90.0, [self imageSize].width,
                                              [self imageSize].height);

    if (destImageRep == nil)
    {
        #ifdef DEBUG
            GeneralMessage ("getting image representation");
        #endif

        destImageRep = [[[NSBitmapImageRep alloc]
                        initWithBitmapDataPlanes:(unsigned char **) onScreenDataPointer
                                      pixelsWide:[self imageWidth]
                                      pixelsHigh:[self imageHeight]
                                   bitsPerSample:(8 * sizeof (DisplayDataType))
                                 samplesPerPixel:1
                                        hasAlpha:NO
                                        isPlanar:NO
                                  colorSpaceName:NSCalibratedWhiteColorSpace
                                     bytesPerRow:([self imageWidth] *
                                                  sizeof (DisplayDataType))
                                    bitsPerPixel:(8 * sizeof (DisplayDataType))]
                        autorelease];
    }

    myView = [[NSImageView alloc] initWithFrame: tempRect];

    [myView setAutoresizesSubviews: YES];

    [myView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];

    myImage = [[[NSImage alloc] initWithSize:[myView bounds].size] autorelease];

    [myImage setScalesWhenResized: YES];

    [myImage setSize: [myView bounds].size];

    [myImage addRepresentation: destImageRep];

    [myView setImage: myImage];

    /* Create a window */
    if ( myWindow == nil ) /* if not already created */
    {
        #ifdef DEBUG
            GeneralMessage ("Creating window ...");
        #endif

        myWindow  = [[NSWindow alloc]
                     initWithContentRect:tempRect
                               styleMask:NSClosableWindowMask |
                                         NSTitledWindowMask |
                                         NSMiniaturizableWindowMask |
                                         NSResizableWindowMask |
                                         NSTexturedBackgroundWindowMask
                                 backing:NSBackingStoreBuffered
                                   defer:false];
    }

    [myWindow setContentAspectRatio:   [self imageSize]];
    [myWindow setContentMinSize:       [self imageSize]];
    [myWindow setContentView:           myView];
    [myWindow setContentSize:          [self imageSize]];

    [myWindow makeKeyAndOrderFront: nil];




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Image (or view ?) not scaling with window
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: Change font and text color of label which is a static NSTextField
  • Next by Date: Re: Internationalizing Bundle Icon
  • Previous by thread: Re: Change font and text color of label which is a static NSTextField
  • Next by thread: Re: Image (or view ?) not scaling with window
  • Index(es):
    • Date
    • Thread