[comp.lang.postscript] fast rendering of 1-bit deep images

yost@esquire.UUCP (David A. Yost) (03/02/90)

Could someone please post a PostScript routine
that will print an m x n one-bit-deep image at
device resolution?

Thanks.

 --dave yost
   yost@dpw.com or uunet!esquire!yost
   Please ignore the From or Reply-To fields above, if different.

zben@umd5.umd.edu (Ben Cranston) (03/03/90)

In article <1822@esquire.UUCP> yost@esquire.UUCP (David A. Yost) writes:

> Could someone please post a PostScript routine
> that will print an m x n one-bit-deep image at
> device resolution?

Unless you like inverting matrices in Postscript, looks like the best bet
is to

m n idtransform scale

then to image the picture as usual.  This version of the Turkey example from
page 171 of the Red book or page 149 of the Blue book prints a nice tenth-
inch turkey, which is about right (24/300 ~= 1/10...).

%!
/inch { 72 mul } def
/picstr 3 string def

/imageturkey {
	24 23 idtransform scale
        24 23 1
	[24 0 0 -23 0 23]
        {currentfile picstr readhexstring pop}
        image
} def

gsave
        3 inch 4 inch translate
        imageturkey
	FFC4FF FFD8FF FFDB7F F1B6BF
	EEB6DF EB4DDF C349AF 8A0177
	E80073 E8A0EB E3F81D C7FC3B
	8FCE7D 071203 4D443D 44907B
	CE403D E715C3 F1C1FF F803FF
	FC07FF E1E7FF E007FF
grestore

showpage

-- 
Sig     DS.L    ('ZBen')       ; Ben Cranston <zben@Trantor.UMD.EDU>
* Network Infrastructures Group, Computer Science Center
* University of Maryland at College Park
* of Ulm

zben@umd5.umd.edu (Ben Cranston) (03/03/90)

Didn't really look at those tiny turkeys until after posting.  Some devices
invert the X or Y scales between user and device coordinates.  Looks like
better bet is:

m n idtransform abs exch abs exch scale

which forces the distance vector components to be positive.

%!
/inch { 72 mul } def
/picstr 3 string def

/imageturkey {
	24 23 idtransform abs exch abs exch scale
        24 23 1
	[24 0 0 -23 0 23]
        {currentfile picstr readhexstring pop}
        image
} def

gsave
        3 inch 4 inch translate
        imageturkey
	FFC4FF FFD8FF FFDB7F F1B6BF
	EEB6DF EB4DDF C349AF 8A0177
	E80073 E8A0EB E3F81D C7FC3B
	8FCE7D 071203 4D443D 44907B
	CE403D E715C3 F1C1FF F803FF
	FC07FF E1E7FF E007FF
grestore

showpage

-- 
Sig     DS.L    ('ZBen')       ; Ben Cranston <zben@Trantor.UMD.EDU>
* Network Infrastructures Group, Computer Science Center
* University of Maryland at College Park
* of Ulm