[comp.lang.postscript] Generating bitmaps from Ghostscript

ghost@aladdin.com (L. Peter Deutsch) (05/13/91)

In message <9105130427.AA12576@wheat-chex> <1047@nlbull.bull.nl>, Jos
Vos asks how to generate bitmaps from Ghostscript.  First he tried:
	gs -DNODISPLAY
	(ps2image.ps) run
	(/tmp/mybitmap.ps) ps2image
The reason this doesn't work is that to create an image (bitmap)
device, Ghostscript needs to know the page size, resolution,
orientation, and palette.  ps2image takes these from the device that
is current at the time you invoke the ps2image procedure.  If you
start up Ghostscript with -DNODISPLAY and never select a device, the
current device is a "null device", which is not suitable.

The second try
	gs
	% here an X11 window was opened
	(ps2image.ps) run
	(/tmp/mybitmap.ps) ps2image
	(program.ps) run
should have worked, but Vos reports:
     Now, gs creates /tmp/mybitmap.ps, but the size stays zero,
     and gs hangs forever...
It may simply be that Ghostscript takes a long time to write the
image.  The code for dumping out the bitmap in this case is written
in PostScript, and is quite slow.

As an alternative, I suggest using the pstoppm utility, which writes
out PPM files instead of a PostScript `image'.  The file writing code
for this utility is written in C.

I would still like to track down the problem with ps2image, of
course.  If it is just a performance problem, I'm not averse to
adding new C operators to solve it.

L. Peter Deutsch :: Aladdin Enterprises :: P.O. box 60264, Palo Alto, CA 94306
ghost@aladdin.com ; ...decwrl!aladdin!ghost ; (415)322-0103 <<< new phone #
	    "Implementation is the sincerest form of flattery."

jos@bull.nl (Jos Vos) (05/14/91)

In article <89.UUL1.3#5127@aladdin.com> ghost@aladdin.com (L. Peter Deutsch) writes:

>It may simply be that Ghostscript takes a long time to write the
>image.  The code for dumping out the bitmap in this case is written
>in PostScript, and is quite slow.

Yep. It took about 7 (!!!) minutes to see the first byte in the file...

But the problem is already solved: yesterday evening I wrote two own
drivers, one test driver for getting the bitmap and one driver for my
non-standard laserprinter. And it works.

-- 
--    Jos Vos <jos@bull.nl>    (UUCP: ...!{uunet,mcsun,hp4nl}!nlbull!jos)
--    Bull Nederland NV, Product Support Unix, Amsterdam, The Netherlands