If you want to use a color image as a pattern, you must use the 5 operand
version of the colorimage command. It will not accept the dictionary
version of the command. Apparently this is because the colorimage command
does not require the current colorspace to be specified.
If you then want to apply an imagemask to it, you must also use the 5
operand version of imagemask, rather than the dictionary version. I don't
really understand why, but that's the way it is.
And you cannot use TilingType 2 in your pattern, I believe.
So my working code looks like this:
[...headers deleted...]
currentfile 4096 string
%%BeginBinary: 4107
readstring
[...4096 bytes deleted...]
%%EndBinary
pop
/ImageData exch def
/ImageDraw {
32 32 scale
32 32 8
[ 32 0 0 -32 0 32 ]
{ ImageData }
false 4
colorimage
} bind def
<<
/PatternType 1
/PaintType 1
/TilingType 1
/BBox [ 0 0 32 32 ]
/XStep 32
/YStep 32
/PaintProc {
begin
ImageDraw
end
}
>>
matrix
makepattern
/ImagePat exch def
/Pattern setcolorspace
ImagePat setcolor
72 72 scale
currentfile 128 string
%%BeginBinary: 139
readstring
[...128 bytes of mask data deleted...]
%%EndBinary
pop
/MaskData exch def
32 32 true [ 32 0 0 -32 0 32 ] { MaskData }
imagemask
showpage
I hope that's helpful to someone!
Darrin
--
Darrin Cardani
>
> Thanks to Martin Bailey for his help with getting an image into a pattern
> so I could apply an imagemask to it. For those of you who are interested, I
> learned the following things in my search:
>
> If you want to use a color image as a pattern, you must use the 5 operand
> version of the colorimage command. It will not accept the dictionary
> version of the command. Apparently this is because the colorimage command
> does not require the current colorspace to be specified.
>
> If you then want to apply an imagemask to it, you must also use the 5
> operand version of imagemask, rather than the dictionary version. I don't
> really understand why, but that's the way it is.
>
> And you cannot use TilingType 2 in your pattern, I believe.
You should be able to use TilingType 2. The tiling type is independent of the
contents of the pattern.
a.
--
Angus Duggan, Harlequin Inc, 301 Ravenswood Ave, | PSUtils 1.17 selects, n-up,
Suite 100, Menlo Park, CA 94025, U.S.A. | booklet & more. Anon ftp from
http://www.dcs.ed.ac.uk/home/ajcd/psutils/ | ftp.dcs.ed.ac.uk:pub/ajcd
http://www.tardis.ed.ac.uk/~ajcd/psutils/ | ftp.tardis.ed.ac.uk:users/ajcd
> fake_email@fake_address.com (Darrin Cardani) writes:
>
> > And you cannot use TilingType 2 in your pattern, I believe.
>
> You should be able to use TilingType 2. The tiling type is independent of the
> contents of the pattern.
After rereading the section in the red book, I think what I originally read
was that the PaintType cannot be 2, which specifies an uncolored pattern.
If you're trying to use a color image, you must specify a PaintType of 1,
which means colored pattern.
Sorry for the confusion,
Darrin
--
Darrin Cardani