Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!adobe!hawley From: hawley@adobe.COM (Steve Hawley) Newsgroups: comp.lang.postscript Subject: Re: reading image data Message-ID: <12925@adobe.UUCP> Date: 20 Mar 91 18:34:44 GMT References: <21257@shlump.nac.dec.com> Reply-To: hawley@adobe.UUCP (Steve Hawley) Organization: Adobe Systems Incorporated, Mountain View Lines: 86 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