This is displaying-an-image:-how? in view mode; [Up]
Date: Sun 23-Jun-1991 21:06:36 From: dcarpent@sjuphil.uucp (D. Carpenter) Subject: displaying an image: how? Could some compassionate soul tell me what is lacking in the code below? I am trying to write a method that, in response to a button click, will find a tiff image, create a window for it, size the window to the size of the image, and then display it on screen. Probably fairly simple for people who, unlike me, know what they are doing. I have managed to get the window created, and sized to the image, but I can't get the image to display. I haven't explicitly created a View for the window, so perhaps there is nothing to composite into? How would I do this? Here's what I have so far: - displayImage:sender { myImage = [ [NXImage alloc] initFromFile: "/me/anImage.tiff" ]; [myImage getSize:&imageSize]; NXSetRect (&rect, 500.0, 350.0, imageSize.width, imageSize.height); myWindow = [Window newContent:&rect style:NX_TITLEDSTYLE backing:NX_BUFFERED buttonMask:NX_CLOSEBUTTONMASK defer:YES]; [[myWindow display] makeKeyAndOrderFront:self]; [myImage composite:NX_COPY toPoint:&(rect.origin)]; return self; } Thanks in advance for any help.
Date: Sun 24-Jun-1991 22:07:57 From: wb1j+@andrew.cmu.edu (William M. Bumgarner) Subject: Re: displaying an image: how? Excerpts From Captions of netnews.comp.sys.next: 23-Jun-91 displaying an >- displayImage:sender >{ > myImage = [ [NXImage alloc] initFromFile: "/me/anImage.tiff" ]; > [myImage getSize:&imageSize]; > > NXSetRect (&rect, 500.0, 350.0, imageSize.width, > imageSize.height); > myWindow = [Window newContent:&rect > style:NX_TITLEDSTYLE > backing:NX_BUFFERED > buttonMask:NX_CLOSEBUTTONMASK > defer:YES]; > [[myWindow display] makeKeyAndOrderFront:self]; > > [myImage composite:NX_COPY toPoint:&(rect.origin)]; > return self; >} You need to lockFocus on a view before compositing the image to the screen/window/view.... Probably, the easiest way for you to do that would be to do this: [[myWindow contentView] lockFocus]; // lock focus on the window's content // view [myImage composite:NX_COPY toPoint:&(rect.origin)]; // blast the image [[myWindow contentView] unlockFocus]; // return to last state [myWindow flushWindow]; // flush the contents to the screen -- this is // neccessary because you have a NX_BUFFERED window --- As a side note, to kill the flicker of teh window coming onto the screen and then the image appearing after that, do this: change the defer:YES to defer:NO -- this will create the window immediately instead of waiting until it is moved to the screen. then do: [myWindow display]; ... the above compositing code ... [myWindow makeKeyAndOrderFront:self]; message is actually necessary, but have a feeling it is or else the contents of the window will come up w/o the widgets being correctly drawn. b.bum OAC -- Objective Arts Consulting <<- might be the name... not sure yet. b.bumgarner | Disclaimer: All opinions expressed are my own. wb1j+@andrew.cmu.edu | I officially don't represent anyone unless I NeXT Campus Consultant | explicity say I am doing so. So there. <Thpppt!> "I ride tandem with the random/Things don't run the way I planned them.."
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.