Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1289 > unrolled thread

Re: Followup: Making an image into a pattern

Started byalamraquib@gmail.com
First post2013-03-07 04:57 -0800
Last post2013-03-11 06:17 -0700
Articles 6 — 3 participants

Back to article view | Back to comp.lang.postscript

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Followup: Making an image into a pattern alamraquib@gmail.com - 2013-03-07 04:57 -0800
    Re: Followup: Making an image into a pattern John Deubert <john@acumentraining.com> - 2013-03-07 05:55 -0800
    Re: Followup: Making an image into a pattern John Deubert <john@acumentraining.com> - 2013-03-07 06:59 -0800
      Re: Followup: Making an image into a pattern John Deubert <john@acumentraining.com> - 2013-03-07 07:16 -0800
        Re: Followup: Making an image into a pattern luser- -droog <mijoryx@yahoo.com> - 2013-03-10 22:53 -0700
          Re: Followup: Making an image into a pattern John Deubert <john@acumentraining.com> - 2013-03-11 06:17 -0700

#1289 — Re: Followup: Making an image into a pattern

Fromalamraquib@gmail.com
Date2013-03-07 04:57 -0800
SubjectRe: Followup: Making an image into a pattern
Message-ID<d7b639ca-28cd-4922-9583-67edf417cdcd@googlegroups.com>
On Friday, September 25, 1998 12:30:00 PM UTC+5:30, Darrin Cardani wrote:
> 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.
> 
> 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

Hello,
I am also working on the Patterns in PostScript.
My image Data size is more than 65535. How that can be done. Could you please provide a solution.

[toc] | [next] | [standalone]


#1290

FromJohn Deubert <john@acumentraining.com>
Date2013-03-07 05:55 -0800
Message-ID<2013030705554335162-john@acumentrainingcom>
In reply to#1289
On 2013-03-07 12:57:17 +0000, alamraquib@gmail.com said:

> On Friday, September 25, 1998 12:30:00 PM UTC+5:30, Darrin Cardani wrote:
>> 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.
>> 
>> 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
> 
> Hello,
> I am also working on the Patterns in PostScript.
> My image Data size is more than 65535. How that can be done. Could you 
> please provide a solution.


Hi -

Issues 21-23 (December 2002 - February 2003) of the Acumen Journal 
present a lengthy discussion of the using images (of arbitrary size) in 
a PostScript form; the techniques presented apply also to using images 
in a pattern.

The Journal is free for the downloading at 
www.acumentraining.com/acumenjournal.html.

- John

-- 
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

[toc] | [prev] | [next] | [standalone]


#1291

FromJohn Deubert <john@acumentraining.com>
Date2013-03-07 06:59 -0800
Message-ID<2013030706595248191-john@acumentrainingcom>
In reply to#1289
On 2013-03-07 12:57:17 +0000, alamraquib@gmail.com said:

> On Friday, September 25, 1998 12:30:00 PM UTC+5:30, Darrin Cardani wrote:
>> 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.
>> 
>> 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
> 
> Hello,
> I am also working on the Patterns in PostScript.
> My image Data size is more than 65535. How that can be done. Could you 
> please provide a solution.

Hi, Darrin -

Actually, the modern versions of image and imagemask work perfectly 
well with an image-based pattern. Here's an example:

=========== Cut here =============

/ImageData  <
	ff0000 ff0000 00ff00
	00ff00 00ff00 0000ff
	0000ff 0000ff ff0000
> def


/ImagePat	<<
	/PatternType    1
	/PaintType      1
	/TilingType     1
	/BBox           [ 0 0 9 9 ]
	/XStep          12
	/YStep          12
	
	/DoImage {
		/DeviceRGB setcolorspace
		9 9 scale
		<<
			/ImageType 1
			/Width 3
			/Height 3
			/BitsPerComponent 8
			/ImageMatrix	[ 3 0 0 -3 0 3 ]
			/DataSource ImageData
			/Decode [ 0 1 0 1 0 1 ]
		>> image
	} bind

	/PaintProc  {
		begin
		DoImage
		end
	}
>>
matrix
makepattern
def

/Pattern ImagePat setpattern

275 375 translate
72 72 scale

<<
	/ImageType 1
	/Width 50
	/Height 50
	/BitsPerComponent 1
	/ImageMatrix [ 50 0 0 -50 0 50 ]
	/DataSource currentfile
		/ASCII85Decode filter
		/LZWDecode filter
	/Decode [ 0 1 ]
>>
imagemask
J3Vsg3$]7K#&$;kY]q,L"Nu?=!&.@P!X-u'3$Q^>KPe$sNko5'p\XY>!0T5cnjja6
IfG)9fY@f@%VIG45`ib]r"1#5J'MEZq?.:a&"p^jkR']arC`qETChaU*X;NaYU[tS
rF(3YJ%jh/Jbt&8!djtJ('\W9eIuLYj.H[IZK6+`[@cjpPZd*p^;&ATp'&$0_8B6W
(7AV9]/6KsT9De[:FA$(5GsLMp1AjQcVbhs2u!HV0%,8UHAeT!)$H>mi(YU*~>

showpage

=========== Cut here =============

I happened to have much of this code lying around in examples from 
various classes I teach.

- John

-- 
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

[toc] | [prev] | [next] | [standalone]


#1292

FromJohn Deubert <john@acumentraining.com>
Date2013-03-07 07:16 -0800
Message-ID<2013030707161752834-john@acumentrainingcom>
In reply to#1291
On 2013-03-07 14:59:52 +0000, John Deubert said:

> On 2013-03-07 12:57:17 +0000, alamraquib@gmail.com said:
> 
>> On Friday, September 25, 1998 12:30:00 PM UTC+5:30, Darrin Cardani wrote:
>>> 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.
>>> 
>>> 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
>> 
>> Hello,
>> I am also working on the Patterns in PostScript.
>> My image Data size is more than 65535. How that can be done. Could you 
>> please provide a solution.
> 
> Hi, Darrin -
> 
> Actually, the modern versions of image and imagemask work perfectly 
> well with an image-based pattern. Here's an example:
> 
> =========== Cut here =============
> 
> /ImageData  <
> 	ff0000 ff0000 00ff00
> 	00ff00 00ff00 0000ff
> 	0000ff 0000ff ff0000
>> def
> 
> 
> /ImagePat	<<
> 	/PatternType    1
> 	/PaintType      1
> 	/TilingType     1
> 	/BBox           [ 0 0 9 9 ]
> 	/XStep          12
> 	/YStep          12
> 	
> 	/DoImage {
> 		/DeviceRGB setcolorspace
> 		9 9 scale
> 		<<
> 			/ImageType 1
> 			/Width 3
> 			/Height 3
> 			/BitsPerComponent 8
> 			/ImageMatrix	[ 3 0 0 -3 0 3 ]
> 			/DataSource ImageData
> 			/Decode [ 0 1 0 1 0 1 ]
> 		>> image
> 	} bind
> 
> 	/PaintProc  {
> 		begin
> 		DoImage
> 		end
> 	}
>>> 
> matrix
> makepattern
> def
> 
> /Pattern ImagePat setpattern
> 
> 275 375 translate
> 72 72 scale
> 
> <<
> 	/ImageType 1
> 	/Width 50
> 	/Height 50
> 	/BitsPerComponent 1
> 	/ImageMatrix [ 50 0 0 -50 0 50 ]
> 	/DataSource currentfile
> 		/ASCII85Decode filter
> 		/LZWDecode filter
> 	/Decode [ 0 1 ]
>>> 
> imagemask
> J3Vsg3$]7K#&$;kY]q,L"Nu?=!&.@P!X-u'3$Q^>KPe$sNko5'p\XY>!0T5cnjja6
> IfG)9fY@f@%VIG45`ib]r"1#5J'MEZq?.:a&"p^jkR']arC`qETChaU*X;NaYU[tS
> rF(3YJ%jh/Jbt&8!djtJ('\W9eIuLYj.H[IZK6+`[@cjpPZd*p^;&ATp'&$0_8B6W
> (7AV9]/6KsT9De[:FA$(5GsLMp1AjQcVbhs2u!HV0%,8UHAeT!)$H>mi(YU*~>
> 
> showpage
> 
> =========== Cut here =============
> 
> I happened to have much of this code lying around in examples from 
> various classes I teach.
> 
> - John

Hmmm. I see that several of the less-than symbols got mangled by my 
newsreader, so none of the dictionaries are closed. Odd. I assume you 
can figure out where they go.

Here's a dropbox link to an unmangled version of the code:

	https://dl.dropbox.com/u/29544294/ImagePatternExample.ps

I'll leave it there for a week or so.

- J

-- 
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

[toc] | [prev] | [next] | [standalone]


#1305

Fromluser- -droog <mijoryx@yahoo.com>
Date2013-03-10 22:53 -0700
Message-ID<0abf3b75-8685-4eb6-9f95-1811c04eeaf0@googlegroups.com>
In reply to#1292
On Thursday, March 7, 2013 9:16:17 AM UTC-6, John Deubert wrote:
> On 2013-03-07 14:59:52 +0000, John Deubert said:
> 
> 
> 
> > On 2013-03-07 12:57:17 +0000, alamraquib@gmail.com said:
> 
> > 
> 
> >> On Friday, September 25, 1998 12:30:00 PM UTC+5:30, Darrin Cardani wrote:
> 
> >>> 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.
> 
> >>> 
> 
> >>> 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
> 
> >> 
> 
> >> Hello,
> 
> >> I am also working on the Patterns in PostScript.
> 
> >> My image Data size is more than 65535. How that can be done. Could you 
> 
> >> please provide a solution.
> 
> > 
> 
> > Hi, Darrin -
> 
> > 
> 
> > Actually, the modern versions of image and imagemask work perfectly 
> 
> > well with an image-based pattern. Here's an example:
> 
> > 
> 
> > =========== Cut here =============
> 
> > 
> 
> > /ImageData  <
> 
> > 	ff0000 ff0000 00ff00
> 
> > 	00ff00 00ff00 0000ff
> 
> > 	0000ff 0000ff ff0000
> 
> >> def
> 
> > 
> 
> > 
> 
> > /ImagePat	<<
> 
> > 	/PatternType    1
> 
> > 	/PaintType      1
> 
> > 	/TilingType     1
> 
> > 	/BBox           [ 0 0 9 9 ]
> 
> > 	/XStep          12
> 
> > 	/YStep          12
> 
> > 	
> 
> > 	/DoImage {
> 
> > 		/DeviceRGB setcolorspace
> 
> > 		9 9 scale
> 
> > 		<<
> 
> > 			/ImageType 1
> 
> > 			/Width 3
> 
> > 			/Height 3
> 
> > 			/BitsPerComponent 8
> 
> > 			/ImageMatrix	[ 3 0 0 -3 0 3 ]
> 
> > 			/DataSource ImageData
> 
> > 			/Decode [ 0 1 0 1 0 1 ]
> 
> > 		>> image
> 
> > 	} bind
> 
> > 
> 
> > 	/PaintProc  {
> 
> > 		begin
> 
> > 		DoImage
> 
> > 		end
> 
> > 	}
> 
> >>> 
> 
> > matrix
> 
> > makepattern
> 
> > def
> 
> > 
> 
> > /Pattern ImagePat setpattern
> 
> > 
> 
> > 275 375 translate
> 
> > 72 72 scale
> 
> > 
> 
> > <<
> 
> > 	/ImageType 1
> 
> > 	/Width 50
> 
> > 	/Height 50
> 
> > 	/BitsPerComponent 1
> 
> > 	/ImageMatrix [ 50 0 0 -50 0 50 ]
> 
> > 	/DataSource currentfile
> 
> > 		/ASCII85Decode filter
> 
> > 		/LZWDecode filter
> 
> > 	/Decode [ 0 1 ]
> 
> >>> 
> 
> > imagemask
> 
> > J3Vsg3$]7K#&$;kY]q,L"Nu?=!&.@P!X-u'3$Q^>KPe$sNko5'p\XY>!0T5cnjja6
> 
> > IfG)9fY@f@%VIG45`ib]r"1#5J'MEZq?.:a&"p^jkR']arC`qETChaU*X;NaYU[tS
> 
> > rF(3YJ%jh/Jbt&8!djtJ('\W9eIuLYj.H[IZK6+`[@cjpPZd*p^;&ATp'&$0_8B6W
> 
> > (7AV9]/6KsT9De[:FA$(5GsLMp1AjQcVbhs2u!HV0%,8UHAeT!)$H>mi(YU*~>
> 
> > 
> 
> > showpage
> 
> > 
> 
> > =========== Cut here =============
> 
> > 
> 
> > I happened to have much of this code lying around in examples from 
> 
> > various classes I teach.
> 
> > 
> 
> > - John
> 
> 
> 
> Hmmm. I see that several of the less-than symbols got mangled by my 
> 
> newsreader, so none of the dictionaries are closed. Odd. I assume you 
> 
> can figure out where they go.
> 
> 
> 
> Here's a dropbox link to an unmangled version of the code:
> 
> 
> 
> 	https://dl.dropbox.com/u/29544294/ImagePatternExample.ps
> 
> 
> 
> I'll leave it there for a week or so.
> 
> 
> 
> - J
> 

Uh, you did see the original message was from 1998, right?

[toc] | [prev] | [next] | [standalone]


#1308

FromJohn Deubert <john@acumentraining.com>
Date2013-03-11 06:17 -0700
Message-ID<20130311061746163-john@acumentrainingcom>
In reply to#1305
On 2013-03-11 05:53:35 +0000, luser- -droog said:

> On Thursday, March 7, 2013 9:16:17 AM UTC-6, John Deubert wrote:
>> On 2013-03-07 14:59:52 +0000, John Deubert said:
>> 
>> 
>> 
>>> On 2013-03-07 12:57:17 +0000, alamraquib@gmail.com said:
>> 
>>> 
>> 
>>>> On Friday, September 25, 1998 12:30:00 PM UTC+5:30, Darrin Cardani wrote:
>> 
>>>>> 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.
>> 
>>>>> 
>> 
>>>>> 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
>> 
>>>> 
>> 
>>>> Hello,
>> 
>>>> I am also working on the Patterns in PostScript.
>> 
>>>> My image Data size is more than 65535. How that can be done. Could you
>> 
>>>> please provide a solution.
>> 
>>> 
>> 
>>> Hi, Darrin -
>> 
>>> 
>> 
>>> Actually, the modern versions of image and imagemask work perfectly
>> 
>>> well with an image-based pattern. Here's an example:
>> 
>>> 
>> 
>>> =========== Cut here =============
>> 
>>> 
>> 
>>> /ImageData  <
>> 
>>> 	ff0000 ff0000 00ff00
>> 
>>> 	00ff00 00ff00 0000ff
>> 
>>> 	0000ff 0000ff ff0000
>> 
>>>> def
>> 
>>> 
>> 
>>> 
>> 
>>> /ImagePat	<<
>> 
>>> 	/PatternType    1
>> 
>>> 	/PaintType      1
>> 
>>> 	/TilingType     1
>> 
>>> 	/BBox           [ 0 0 9 9 ]
>> 
>>> 	/XStep          12
>> 
>>> 	/YStep          12
>> 
>>> 	
>> 
>>> 	/DoImage {
>> 
>>> 		/DeviceRGB setcolorspace
>> 
>>> 		9 9 scale
>> 
>>> 		<<
>> 
>>> 			/ImageType 1
>> 
>>> 			/Width 3
>> 
>>> 			/Height 3
>> 
>>> 			/BitsPerComponent 8
>> 
>>> 			/ImageMatrix	[ 3 0 0 -3 0 3 ]
>> 
>>> 			/DataSource ImageData
>> 
>>> 			/Decode [ 0 1 0 1 0 1 ]
>> 
>>> 		>> image
>> 
>>> 	} bind
>> 
>>> 
>> 
>>> 	/PaintProc  {
>> 
>>> 		begin
>> 
>>> 		DoImage
>> 
>>> 		end
>> 
>>> 	}
>> 
>>>>> 
>> 
>>> matrix
>> 
>>> makepattern
>> 
>>> def
>> 
>>> 
>> 
>>> /Pattern ImagePat setpattern
>> 
>>> 
>> 
>>> 275 375 translate
>> 
>>> 72 72 scale
>> 
>>> 
>> 
>>> <<
>> 
>>> 	/ImageType 1
>> 
>>> 	/Width 50
>> 
>>> 	/Height 50
>> 
>>> 	/BitsPerComponent 1
>> 
>>> 	/ImageMatrix [ 50 0 0 -50 0 50 ]
>> 
>>> 	/DataSource currentfile
>> 
>>> 		/ASCII85Decode filter
>> 
>>> 		/LZWDecode filter
>> 
>>> 	/Decode [ 0 1 ]
>> 
>>>>> 
>> 
>>> imagemask
>> 
>>> J3Vsg3$]7K#&$;kY]q,L"Nu?=!&.@P!X-u'3$Q^>KPe$sNko5'p\XY>!0T5cnjja6
>> 
>>> IfG)9fY@f@%VIG45`ib]r"1#5J'MEZq?.:a&"p^jkR']arC`qETChaU*X;NaYU[tS
>> 
>>> rF(3YJ%jh/Jbt&8!djtJ('\W9eIuLYj.H[IZK6+`[@cjpPZd*p^;&ATp'&$0_8B6W
>> 
>>> (7AV9]/6KsT9De[:FA$(5GsLMp1AjQcVbhs2u!HV0%,8UHAeT!)$H>mi(YU*~>
>> 
>>> 
>> 
>>> showpage
>> 
>>> 
>> 
>>> =========== Cut here =============
>> 
>>> 
>> 
>>> I happened to have much of this code lying around in examples from
>> 
>>> various classes I teach.
>> 
>>> 
>> 
>>> - John
>> 
>> 
>> 
>> Hmmm. I see that several of the less-than symbols got mangled by my
>> 
>> newsreader, so none of the dictionaries are closed. Odd. I assume you
>> 
>> can figure out where they go.
>> 
>> 
>> 
>> Here's a dropbox link to an unmangled version of the code:
>> 
>> 
>> 
>> 	https://dl.dropbox.com/u/29544294/ImagePatternExample.ps
>> 
>> 
>> 
>> I'll leave it there for a week or so.
>> 
>> 
>> 
>> - J
>> 
> 
> Uh, you did see the original message was from 1998, right?

I can be remarkably unobservant sometimes.

Oh, well. Not the most embarrassing thing I've ever done.

Maybe he was still chewing on the problem. These things can obsess one, 
you know.

- J

-- 
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.postscript


csiph-web