advertisement

Article:
  Working With Bitmap Images; Document-Based Application Redux
Subject:   Adding loading an image at launch time
Date:   2002-04-27 17:03:17
From:   michele
With the aim of implementing drag and drop in the application, I've added the loading of an image at launch time.


Loading an image at launch time (another option is to run a modal panel to force opening a file).


1 - Make a tiff image. Add it to the project (with copy items ... if needed checked).


2 - Add a method to MyDocument.h to load the image


- (void) setActiveImage: (NSString *) aString;


3 - Implement the method in MyDocument.m


- (void) setActiveImage: (NSString *) aString
{
activeImage: [NSImage imageNamed: aString];
}


4 - Change the windowDidLoad method in IAWindowController.m


- (void) windowDidLoad
{
NSImage *image;
if ([[self document] activeImage] == nil)
{
[[self document] setActiveImage: @"lave"];
}
image = [[self document] activeImage];

[view setImage: image];
[self scaleImageTo: 1.0];
}


if the loaded image is named lave.tiff, just give the name without extension as parameter to setActiveImage.



1 to 1 of 1
  1. Adding loading an image at launch time
    2002-05-02 12:56:07  psheldon [View]

    • Adding loading an image at launch time
      2002-05-03 12:13:44  michele [View]

1 to 1 of 1