gtravan@sirius.ua.oz (George Travan) (10/20/88)
could someone provide a NeWS novice with some relevant demo code to display 8 bit graylevel images? I have some 512*512*8 bit images which i would like to display using NeWS. (each byte represents a pixel gray level). I generate these files from my C programs so i would be most interested in C client postscript interface procedures. any help would be appreciated. george travan ACSNET: gtravan@sirius.ua.oz
scout@campfire.Sun.COM (David LaVallee) (10/25/88)
In article <144@sirius.ua.oz> gtravan@sirius.ua.oz (George Travan) writes: > > could someone provide a NeWS novice with some relevant demo code to display >8 bit graylevel images? I have some 512*512*8 bit images which i would like >to display using NeWS. (each byte represents a pixel gray level). I generate >these files from my C programs so i would be most interested in C client >postscript interface procedures. any help would be appreciated. > > george travan ACSNET: gtravan@sirius.ua.oz > The image and buildimage operators in NeWS create canvases (canvi) at various depths: 1 = monochrome, may be used as a bit mask with imagemask operator 4 = grey scale (but I haven't used this one) 8 = grey scale 256 value ramp 24 = true color RGB888 The depth of the image is independant of the output device (screen) depth. I send images over as strings (strings can have characters with values > 128). The caveat is that strings can only be MAXINT long (~35000 characters), most images are larger than that. Therefor I send a string for each scanline into an array of strings, and assemble the image in NeWS out of that structure. Using scanlines makes the C side easier as well, here's a clip from a current hackery project, the performance is good: from display.c: display(pix) /* pix is an array of scanlines */ unsigned char **pix { int y; ps_clear_scanlines(); /* clear the old image */ for (y = 0; y < DEF_Y; y++) /* for each y send the scanline */ ps_scanline(pix[y], DEF_X); ps_repaint() /* push a repaint token */ ps_flush_PostScript(); /* flush those lil'packets */ } from display.cps cdef ps_clear_scanlines() /scanlines [] store cdef ps_scanline(cstring scanline) /scanlines scanlines [scanline] append store cdef ps_repaint() /paintclient win send . . . % the pictures I was using were 250x200x8, this should be generalized /repairpicture { 30 clippath pathbbox insetrect rectpath clip clippath pathbbox 200 div exch 250 div exch min dup scale pop pop clippath pathbbox 2 div 200 2 div sub exch 2 div 250 2 div sub exch translate pop pop 250 200 scale gsave .5 setgray 0 0 1 1 rectpath fill grestore %%%%%%%%%%%%%%%%% %% THIS IS THE IMPORTANT STUFF /next 0 def 250 200 8 [250 0 0 -200 0 200] { scanlines next get /next next 1 add store } image %% %%%%%%%%%%%%%%%%% } def { /PaintClient {repairpicture} def } win send . . . regards, --scout