tatlow@dash.dlb5.dec.com (Tom Tatlow) (03/20/91)
I have a Postscript file containing some image data, and I would like to be able to have the image drawn by a function. However, the proc 776 109 1 [ 776 0 0 -109 0 109] { currentfile picstr readhexstring pop} image reads from the current position in the file (right after the call to the function). Is there any way I can store all of the hex image data in a big array or something and have the image procedure read it from there? What would the procedure that's on the top of the stack before the call to "image" look like? ================================================================== Tom Tatlow "The Question" Work: Digital Equipment Corporation, AI Technology Center tatlow@dash.dlb5.dec.com (508) 490-8500 Home: 59 Pearl Street, #3, Cambridge, MA 02139 tom@math.mit.edu (617) 876-6216 ==================================================================
hawley@adobe.COM (Steve Hawley) (03/21/91)
In article <21257@shlump.nac.dec.com> tatlow@dash.dlb5.dec.com (Tom Tatlow) writes: >I have a Postscript file containing some image data, and I would like to be >able to have the image drawn by a function. > ... >Is there any way I can store all of the hex image data in a big array or >something >and have the image procedure read it from there? What would the >procedure >that's on the top of the stack before the call to "image" look like? This is not too hard to do. Here's a thing I did to draw a page full of Bart Simpsons: %! % Bitmap of Bart Simpson. Drawn and compiled into PostScript % by Steve Hawley, 6/90. The image tiles very well. % /bartbits < 00911114C014200000622228A0162000 8C444448A4C431A914288888AAA42AAB 8C311118C4A229910022222800000000 00244448000014010028888800001C01 00311114092214D90062222412AA1554 00444446091494D50088CCCD40010000 01117AAAC0002000062251117FE04000 FC4440004460FFFF8888C00048C18888 111140005147111122224000629A2222 4444400045E444448888C00048888888 11114000311111112222200022222222 4444601DC44444448888A02228888888 11112041111111112222204552222222 44445041144444448888902228888888 1111101DF11111112222300012222222 44447000144444448888880018888888 1111B000F11111112222A00062222222 44448800244444448888F01FE8888888 11111020111111112222282722222222 44444819444444448888880288888888 11111405111111112222240A222A2222 4547C414F45444448D8C6BEB18948888 3C9A10040927911142FE00040FE86222 700200020801C44488FE00020FE28888 109A0002092111112D2A10021236A222 55446001F45544448A8FA00188888888 111120009111111122222000A2222222 44446000C44444448888C00048888888 11114000511111112222400062222222 44444000444444448888C00048888888 1111400051111111FA223001FFFFFFFF 06444FFE000000000188888C00000000 > def % The bitmap is inverted, so I use this routine to flip all the % bits. 0 1 bartbits length 1 sub { dup bartbits exch get 255 xor bartbits 3 1 roll put } bind for /bart { % width height x y => --- %% procedure to draw an image of Bart Simpson gsave translate scale % bart is 64x64 64 64 1 [64 0 0 -64 0 64] {//bartbits} image grestore } bind def 0 30.71988 800 { % draw a page of barts. 18 exch moveto gsave 0 30.71988 550 { 30.71988 30.71988 currentpoint bart 30.71988 0 rmoveto } for grestore } bind for % this does just a single one % 72 72 300 400 bart showpage Enjoy. Steve Hawley hawley@adobe.com -- "Did you know that a cow was *MURDERED* to make that jacket?" "Yes. I didn't think there were any witnesses, so I guess I'll have to kill you too." -Jake Johansen
kalin@cbnewsm.att.com (andrew.j.kalinowitsch) (03/21/91)
On a related note, is there any way to convert PS instructions that produce a relatively small image into the actual bitmap of the image? I've got a file that makes the printer execute all kinds of funky arctangents and curvetos to produce the exact same image over and over again -- I'd like to get the image in a bitmap without scanning it (and without whipping out the graph paper to do a manual rendering :-) ) to optimize execution time/throughput. Any suggestions? Andy
acli@dahlia.uwaterloo.ca (Ambrose) (03/21/91)
In article <1991Mar20.190919.25355@cbnewsm.att.com> kalin@cbnewsm.att.com (andrew.j.kalinowitsch) writes: >I've got a file that makes the printer execute all kinds of funky >arctangents and curvetos to produce the exact same image over and over >again -- I'd like to get the image in a bitmap without scanning it >to optimize execution time/throughput. The best way to do it is to create a type 3 font and let the font machinery do the job. According to the green book (PostScript language program design) [p.145], this will be *extremely* fast if the image can fit into the font cache. In article <9103191412.AA27314@stork.cs.rochester.edu> bukys@cs.rochester.edu writes: >This is a futile plea, I know, but here it is. > > Please stamp out bad PostScript generators. On a related note, I think the green book is a good start in learning how to avoid writing bad PostScript generators. -Ambrose
mzellers@starnet.uucp (Mark Zellers) (03/22/91)
In article <1991Mar20.190919.25355@cbnewsm.att.com> kalin@cbnewsm.att.com (andrew.j.kalinowitsch) writes: >On a related note, is there any way to convert PS instructions that >produce a relatively small image into the actual bitmap of the image? >I've got a file that makes the printer execute all kinds of funky >arctangents and curvetos to produce the exact same image over and over >again -- I'd like to get the image in a bitmap without scanning it >(and without whipping out the graph paper to do a manual rendering :-) ) >to optimize execution time/throughput. Any suggestions? > >Andy If you want to reuse the same immage again and again on the same printer, the best way to go might well be to define it as a font. It is not very difficult: refer to the PostScript Cookbook and Tutorial (the Blue Book) for an example. Make sure that you use the setcachedevice operator to put your character in the font cache. Then all you need to do to get your image printed out is to select your font, scale and print your character. If it is printed more than once in the same size and orientation, the bits will come out of the cache. If you like, you can store your font in the printer's server loop and it will remain until the printer is turned off. Of course, this does not do you any good if you want the bitmap outside of the printer. In that case, you would be best off using Ghostscript, Freedom of the Press or one of the simmilar PostScript clone packages. Mark H. Zellers marc.com!bwayne!mark
jwz@lucid.com (Jamie Zawinski) (03/22/91)
In article <21257@shlump.nac.dec.com> tatlow@dash.dlb5.dec.com (Tom Tatlow) wrote: > > Is there any way I can store all of the hex image data in a big array or > something and have the image procedure read it from there? Yes, like so: /foobar { gsave -0.5 -0.5 translate 82 71 1 [ 82 0 0 -71 0 71 ] %% bitmap data... pinhead representation (tm). {<000000000000000000003f000000000000000000003f000000000000000000003f00000000 ... ad nauseam ... 000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000>} image grestore } def But note that some on-screen PostScript interpreters have problems with extremely long literal strings, so this might not work there. It should work in all conforming PS implementations, though. -- Jamie
jwz@lucid.com (Jamie Zawinski) (03/22/91)
In article <1991Mar21.021614.7445@watdragon.waterloo.edu> acli@dahlia.uwaterloo.ca (Ambrose) wrote: > In article <1991Mar20.190919.25355@cbnewsm.att.com> kalin@cbnewsm.att.com > (andrew.j.kalinowitsch) writes: >> >>I've got a file that makes the printer execute all kinds of funky >>arctangents and curvetos to produce the exact same image over and over >>again -- I'd like to get the image in a bitmap without scanning it >>to optimize execution time/throughput. > > The best way to do it is to create a type 3 font and let the font machinery > do the job. Once PostScript Level II starts actually showing up in implementations, I think it will be pretty simple to use the "forms" facility to do this. As I understand it, this is an interface to a font-cache-like mechanism without having to go through all the hairy goop necessary to define a font. Until then, I think defining a font is probably the best way. -- Jamie
piyush@applix.com (Piyush Jain [ext 250]) (03/27/91)
From article <1991Mar21.021614.7445@watdragon.waterloo.edu>, by acli@dahlia.uwaterloo.ca (Ambrose): >>I've got a file that makes the printer execute all kinds of funky >>arctangents and curvetos to produce the exact same image over and over > > The best way to do it is to create a type 3 font and let the font machinery > do the job. According to the green book (PostScript language program design) > [p.145], this will be *extremely* fast if the image can fit into the font > cache. > True, font-caching can be really fast. However, I've had cases where printing Type 3 fonts through a non-rectangular clip can take *forever*, many times even longer than the regular method (that is, when it is not defined as a font). -- Piyush Jain piyush@applix.com