java - Converting/writing a BufferedImage to postscript -
i know how draw simple shapes using postcript
i'm looking how draw content bufferedimage(width*height) postscript page (x,y,width,height) without external library (fop,pdfbox...).
do have hint/code/algorithm ?
thanks ! :-)
one has use image
or colorimage
operators. unlike simple linedrawing , show
text operator, these complex operators take several parameters.
i putting sample postscript snippet renders 8 x 8 image using 7 parameter colorimage
operator. take notice 5th parameter callback procedure, may called several times colorimage operator, each time returning of image data in string. in example, return whole image data @ once. in example, data ascii encoded each byte being represented 2-digit hexadecimal number. more efficient encodings possible, postscript can decode base64, base85 , rle encoding in runtime.
this parameter might single string instead of callback procedure, in case, binary data have escaped in octal, preceding slash (like \377) decimal 255. using inline data read currentfile
operator rather usual representing postscript images.
note image mapped (0,0,1,1) square on renderign space, , 1 has set global transformation matrix (with translate
, scale
, rotate
operators) prior rendering image.
the complete image
, colorimage
reference can found on postscript language refrence adobe available @ http://www.adobe.com/products/postscript/pdfs/plrm.pdf
for example, try running gimp
program , saving image postscript within it.
%!ps-adobe-3.0 % builds string hold image data @ once: /imgdata 8 8 3 mul mul string def % set context scale image 256 x 256 pt (from 1 x1 pt) 256 256 scale % dimensions of image (width * height * bpp) 8 8 8 % image transformation matrix - [width 0 0 -height 0 height]: flips % vertical axis have top bottom data: [8 0 0 -8 0 8] % procedure read image data , return string: { currentfile % read inline data imgdata % put read data variable readhexstring % performs reading pop % discards read operation status } %indicates single data source: false %number of colors per pixel: 3 % image operator: consumes previous parameters , renders image % followed image hexadecimal data in ascii colorimage 0000000000200000400000600000800000a00000c00000e0200000200020 2000402000602000802000a02000c02000e0400000400020400040400060 4000804000a04000c04000e06000006000206000406000606000806000a0 6000c06000e08000008000208000408000608000808000a08000c08000e0 a00000a00020a00040a00060a00080a000a0a000c0a000e0c00000c00020 c00040c00060c00080c000a0c000c0c000e0e00000e00020e00040e00060 e00080e000a0e000c0e000e0 showpage
Comments
Post a Comment