ftp.nice.ch/peanuts/GeneralData/Usenet/news/1989/CSN-89.tar.gz#/comp-sys-next/1989/Aug/How-do-I-display-a-byte-image-???

This is How-do-I-display-a-byte-image-??? in view mode; [Up]


Date: Sun 25-Aug-1989 19:08:34 From: Unknown Subject: How do I display a byte image ??? Friends in NXland, I have a LANDSAT image of Washington DC, and I'd like to see how it looks on the MegaPixel display. Can anyone help me with code? The image is 1024X1024 8-bit pixels, and the file has no header -- just 1024 bytes for line 1 followed by 1024 bytes for line 2, etc to EOF, altogether 1 Megabyte. I suppose I would only see 2-bit pixels on the MegaP-display, or can I use the other 2 bits as well? Do I need to use the Interface Builder? Once I load the 1Mb into memory, should I use NXImageBitmap(displaypointer,1024,1024,2,1,NX_PLANAR,0,imagepointer) ???????????????????????????????????????????????????????????????????????? If so, how do I determine displaypointer? I unfortunately have to do most of the work remotely, since the machine itself is 4 miles away. Any help would be much appreciated !!! Thanks. Bob Cahalan NASA-GSFC ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Robert F. Cahalan # Laboratory for Atmospheres cahalan@iris613.gsfc.nasa.gov # NASA-Goddard Space Flight Center frrfc@scfvm (bitnet) # Greenbelt, MD 20771 >From: lacsap@mit-amt.MEDIA.MIT.EDU (Pascal Chesnais)
Date: Sun 25-Aug-1989 21:47:18 From: Unknown Subject: Re: How do I display a byte image ??? It would be a good idea for people to mention if they can receive NeXT attachments in mail. Not that I want to see the network flooded with Voice attachments, but it is quicker for me to drop in a file into a piece of mail, rather than open it in edit, copy and paste into the mail... Besides it is also easier to include real smiley faces with your mail messages:-)... I wonder who will be the first to write a ReadNewsApp for the NeXT? pasc
Date: Sun 02-Sep-1989 16:33:53 From: Unknown Subject: Re: How do I display a byte image ??? In article <438@dftsrv.gsfc.nasa.gov> Bob Cahalan writes: >I have a LANDSAT image of Washington DC, and I'd like >to see how it looks on the MegaPixel display. Can anyone >help me with code? The image is 1024X1024 8-bit pixels, and >the file has no header -- just 1024 bytes for line 1 followed >by 1024 bytes for line 2, etc to EOF, altogether 1 Megabyte. You can try appending a PS header on top of it and executing it in Yap. Here's a header that might work; it worked for me when I added it to the pictures of Neptune & Triton I grabbed off some FTP host. ------------------------------------------------------------------------------ %! /scaleFactor 1 def /width 640 def /height 480 def /depth 8 def /picstr width 8 idiv string def /thedata { width height depth [width 0 0 height neg 0 height] { currentfile picstr readstring pop } image } def width scaleFactor mul height scaleFactor mul scale thedata ------------------------------------------------------------------------------ Cut the section between the lines, save as "header.ps", change the width and height values (to 1024 and 1024), then append it to the front of your data file with cat header.ps yourdatafile > new.ps Then fire Yap up, and open new.ps. You need to be patient; 0.9 Yap can get pretty slow in opening large files. Once it's loaded, execute it; see what you get. I hope it works! The file new.ps won't be previewable; it lacks the correct EPSF header using the above cheapo segment of PostScript. But if it works through Yap, then we can worry about making it correct EPSF. You can also just do a screen grab with Icon or Scene to get a TIFF file. >I suppose I would only see 2-bit pixels on the MegaP-display, >or can I use the other 2 bits as well? PostScript is pretty smart about dithering; it will not waste your 8 bits. Ali Ozer, NeXT Developer Support aozer@NeXT.com >From: izumi@violet.berkeley.edu (Izumi Ohzawa)
Date: Sun 02-Sep-1989 23:54:09 From: Unknown Subject: Re: How do I display a byte image ??? In article <11638@polya.Stanford.EDU> aozer@NeXT.com (Ali Ozer) writes: >In article <438@dftsrv.gsfc.nasa.gov> Bob Cahalan writes: >>help me with code? The image is 1024X1024 8-bit pixels, and >>the file has no header -- just 1024 bytes for line 1 followed >>by 1024 bytes for line 2, etc to EOF, altogether 1 Megabyte. > >You can try appending a PS header on top of it and executing it >in Yap. Here's a header that might work; it worked for me when I Thanks Ali, but is there a way to use the `image` operator in a PSWRAPped function which can receive a pointer to binary image data directly? I think Bob's image file contains a straight binary image. For occasional viewing, your method of viewing with Yap will work well. However, it seems that I should be able to use a pswrapped function of the form: defineps displayBinaryImage( float x, y, width, height; int xnum_pixels, ynum_pixels; int bits_per_pixel; unsigned char *imagedata) ..... endps which will diplay the binary image pointed to by imagedata into a rectangle of 'width' and 'height' with its lower left corner at (x,y). I know that 'image' operator takes a procedure which leaves a (HEX ASCII) string on stack as its last argument, but I am asking if it is possible to directly pass a pointer to binary image data. Is this possible? Izumi Ohzawa, izumi@violet.berkeley.edu >From: farber@linc.cis.upenn.edu (David Farber)
Date: Sun 04-Sep-1989 17:07:15 From: Unknown Subject: Re: How do I display a byte image ??? In article <1989Sep2.235409.8890@agate.uucp> Izumi Ohzawa writes: >Thanks Ali, but is there a way to use the `image` operator >in a PSWRAPped function which can receive a pointer to >binary image data directly? > >I think Bob's image file contains a straight binary image. >For occasional viewing, your method of viewing with Yap will >work well. However, it seems that I should be able to use >a pswrapped function of the form: > >defineps displayBinaryImage( > float x, y, width, height; > int xnum_pixels, ynum_pixels; int bits_per_pixel; > unsigned char *imagedata) > ..... >endps Yes, image can take binary data; in fact, if you append that header to a bunch of binary data and stuff it in Yap it works fine. As far as creating the above pswrap, I believe NXImageBitmap() does what you want. (Bob mentioned NXImageBitmap() in his original message, in fact...) You first lockFocus on the appropriate view or bitmap, then provide the rectangle to image to, the size of the image data (1024 by 1024, in this case), the bits per pixel (8), samples per pixel (1), the data format (NX_PLANAR), mask (0), and five pointers to data: NXRect rect = bounds; // In a view, for instance, you can image to bounds char *data; // // Here point "data" to your image data // NXImageBitmap (&rect, 1024, 1024, 8, 1, NX_PLANAR, 0, data, NULL, NULL, NULL, NULL); Depending on how fast you want to redraw the data, you might want to NXImageBitmap() into a view or bitmap. If are not concerned about redraw speed on scroll or resize, simply lockFocus in your view and call NXImageBitmap(). If you like to redraw the image real fast, then create a bitmap, and draw the image in that. Then composite from the bitmap to your actual view. That way you can forget about the original data and never again incur the cost of imaging the 8 bits down to 2 (as long as your program is running, of course...). Finally, how do you get at the data? Best approach is to probably memory map the file using streams: int maxSize, size; char *data = NULL; NXStream *s = NXMapFile ("datafile", NX_READONLY); if (s) NXGetMemoryBuffer (s, &data, &size, &maxSize); if (data) // You can use the data (there are size bytes of it) Ali Ozer, NeXT Developer Support aozer@NeXT.com >From: userWEAT@ualtamts.BITNET (John Wetherill)

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.