LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-11-2007, 09:17 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Postscript - how to insert an image?


Has anyone ever done any postscript programming? I've got a nice postscript template that I modify for on-the-fly creation of .ps files (to send to the printer, and convert to pdf). I'm having a hard time inserting an image. I glanced through the 900 page doc on the postscript format but it's a bit... verbose. Hard to get to the meat of how to actually do it rather than the theory behind it.

Has anyone inserted an image into a postscript file?
 
Old 07-11-2007, 09:34 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
On my shelf is a book I've used so much it's beginning to fall apart. It's PostScript Language Reference Manual from Adobe Systems Incorporated. Some people call it the Red Book.

It discusses inserting images. I haven't actually done that, but I've read it and understand it. It's not too heavy on theory (whatever "theory" means in PostScript); it's pretty straightforward.

You can get this book used on Amazon.

Hope this helps.
 
Old 07-12-2007, 07:08 AM   #3
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
Ok, you got me interested.

I went to the Red Book and fleshed out their partial example. Run program gs against this and see what you get.

Code:
%!PS-Adobe

% location on page, in points

/lowerleftx     72 def
/lowerlefty    144 def

% size on page, in points

/destwidth     132 def
/destheight     66 def

% size of original image, in pixels

/sourcewidth    32 def
/sourceheight   16 def

% greyscale; two hex digits per pixel, with 00 being black and FF white

/bitspersample   8 def

% string to hold each row

/picstr sourcewidth string def

gsave

lowerleftx lowerlefty translate
destwidth destheight scale

sourcewidth sourceheight bitspersample     % dimensions of source image
[ sourcewidth
  0
  0
  sourceheight neg
  0
  sourceheight
]                                          % coordinate transformation matrix
{ currentfile picstr readhexstring pop }   % getting the data
image

0000000000000000000000000000000000000000000000000000000000000000
00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF0000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF00000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF00000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFF00
00FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
00FF00000000000000000000000000000000000000000000000000000000FF00
00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
0000000000000000000000000000000000000000000000000000000000000000

grestore

showpage
Hope this helps.
 
Old 07-12-2007, 06:47 PM   #4
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by wjevans_7d1@yahoo.co
Ok, you got me interested.

I went to the Red Book and fleshed out their partial example. Run program gs against this and see what you get.....
interesting.... that does help... looks like you just convert each pixel to hex & splat it out in the file.

an excellent starting point. Thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[Latex] Insert image before titlepage chief_officer Linux - Software 4 06-25-2006 12:54 PM
Need some help with Postscript robogymnast Programming 2 01-19-2006 02:56 PM
Creating a postscript output from a image and text rdfoerster Linux - Software 3 08-31-2004 10:26 AM
Postscript Problem E-Oreo Linux - General 0 01-03-2004 06:21 PM
perl script to insert image information rhuser Programming 1 03-12-2003 05:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration