* * *

Author Topic: PostScript (page 01) for preview display via FPvectorial?  (Read 1038 times)

Blestan

  • Sr. Member
  • ****
  • Posts: 451
Re: PostScript (page 01) for preview display via FPvectorial?
« Reply #15 on: August 05, 2017, 03:40:53 pm »
the api has run string to ezexute ps code but i think that max buffer size is 64K ... as i told ps is extremely expensive complex  and slow to run and render
Speak postscript or die!
Translate to pdf and live!

PaulANormanNZ

  • New member
  • *
  • Posts: 35
Re: PostScript (page 01) for preview display via FPvectorial?
« Reply #16 on: August 06, 2017, 03:45:26 am »
Thanks Blestan,

Getting a preview onto a Lazarus canvas is my focus - but how much time would really be saved trying for a more internal Lazarus path, when the main time overhead from what everyone is saying: is the GS processing portion - so writing bmp/jpeg/png to disk and reading the 'preview' back from disk may not be the time overhang I have envisaged and been trying to avoid?

Doing it all from GS DLL should nonetheless be faster than a Shell call; I can assume?

In the background stuff below, there is a test.exe pilot (incomplete) project that appears to actually render a workable preview of a .ps file in Delphi (found in gsapi_delphi.zip)..

Written by Alessandro Briosi with the
// assistance of Russell Lang it all uses a unit gsimage providing TGsImage which gives us:

DISPLAY_COLORS_GRAY,  _RGB,   _CMYK

and Colour depths 1, 4, 8, 16

Offers varying DPI and is quite fast already actually. Looking hopeful.

I think its all under an MIT like license, so this may save some time?

---

Found some background stuff in case it saves any one any time...

The Delphi community have some helpful things--

https://stackoverflow.com/questions/20778134/extracting-plain-text-from-postscript-file-via-gsdll32-dll

The Answer there - GhostTools.pas Class file for GSDLL32.DLL has some helpful top level things.

It uses gsapi.pas no longer available via
 
http://pages.cs.wisc.edu/~ghost/doc/gsapi.htm
and
http://mirror.cs.wisc.edu/pub/mirrors/ghost/contrib/gsapi_delphi.zip

gsapi.pas is findable here though:
http://www.filewatcher.com/m/gsapi_delphi.zip.208923-0.html

And from that bundle specifically this looks helpful:
https://github.com/tristan2468/PDFPrint/blob/master/GhostScript.pas

Some notes here:
http://mseide-msegui-talk.narkive.com/2UJ4ZIAh/ghostscript-api-implementation

Paul
« Last Edit: August 06, 2017, 04:21:12 am by PaulANormanNZ »

PaulANormanNZ

  • New member
  • *
  • Posts: 35
Re: PostScript (page 01) for preview display via FPvectorial?
« Reply #17 on: August 06, 2017, 08:05:37 am »
Ok,

I imported that trial test.dpr into Lazarus from gsapi_delphi.zip

After the import I only had to REM line 192 in gsimage.pas

// was needed ...
// bm.IgnorePalette:=true; 

... I'm not sure whether this needs further research or things are ok as they are now.

Any way it works very well as it is so far.

Certainly adequate for a generalised preview glimpse of PS. Handles pagination and all.

I've attached gasp_delphi.zip there is a readme.txt

Paul

Blestan

  • Sr. Member
  • ****
  • Posts: 451
Re: PostScript (page 01) for preview display via FPvectorial?
« Reply #18 on: August 06, 2017, 08:32:04 am »
good to see that you are advancing !!!
just few more hints from me:
1. try to use as canvas bgrabitap because its very very... as i did for mupdf. it will save alot of drawing time
2. if you want adecuate colors of the preview use litlecms... pascal bindings are perfect.
3. if you render/ saving to a temp file avoid using compressed files like jpg or png this will save alot of decoding time.
4. create please a github repo with all code name it fpc-gs for example i will join
5. create a new theread in the forum under "graphics" section to anounce all gs stuff with others
 :)
blestan
Speak postscript or die!
Translate to pdf and live!

PaulANormanNZ

  • New member
  • *
  • Posts: 35
Re: PostScript (page 01) for preview display via FPvectorial?
« Reply #19 on: August 06, 2017, 10:56:33 am »
Thank you for the suggestions blestan, but I don't believe I have the competency to head up a component development for widespread usage.

May whoever is, and who is willing -please feel free to.

Certainly your experience with mupdf would be a really great basis to work from blestan!

Paul

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus