Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cis.ohio-state.edu!sei.cmu.edu!fs7.ece.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!wb1j+ From: wb1j+@andrew.cmu.edu (William M. Bumgarner) Newsgroups: comp.sys.next Subject: Re: displaying an image: how? Message-ID: Date: 24 Jun 91 22:07:57 GMT References: <1991Jun23.210636.13446@sjuphil.uucp> Organization: Carnegie Mellon, Pittsburgh, PA Lines: 61 In-Reply-To: <1991Jun23.210636.13446@sjuphil.uucp> Excerpts From Captions of netnews.comp.sys.next: 23-Jun-91 displaying an image: how? D. Carpenter@sjuphil.uuc (1304) >- 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]; BTW: I'm doing this from memory-- I can't remember if the display 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. "I ride tandem with the random/Things don't run the way I planned them.."