Welcome to NeoOffice developer notes and announcements
NeoOffice
Developer notes and announcements
 
 

This website is an archive and is no longer active
NeoOffice announcements have moved to the NeoOffice News website


Support
· Forums
· NeoOffice Support
· NeoWiki


Announcements
· Twitter @NeoOffice


Downloads
· Download NeoOffice


  
NeoOffice :: View topic - Looking for APIs to convert PostScript to JPEG, GIF, or PNG
Looking for APIs to convert PostScript to JPEG, GIF, or PNG
 
   NeoOffice Forum Index -> NeoOffice Development
View previous topic :: View next topic  
Author Message
pluby
The Architect
The Architect


Joined: Jun 16, 2003
Posts: 11949

PostPosted: Thu Sep 11, 2003 11:30 am    Post subject: Looking for APIs to convert PostScript to JPEG, GIF, or PNG

I am trying to implement the SalGraphics::DrawEPS() method in VCL and I am running into problems. The problem is that I need to take the EPS passed to the DrawEPS() method and paint that EPS onto a Java Graphics2D object (i.e. the printer page).

My current thinking is that if I can read the EPS into a Java Image object, I can then use Java's Graphics.drawImage() method to paint the EPS onto the printer page.

Unfortunately, Java does supportn reading PostScript into an image. So, the next best alternative would be to convert the EPS to one of the image formats supported by Java: JPEG, GIF, or PNG.

Before someone says "use GhostScript", it is my understanding that GhostScript Mac OS X uses X11 to handle any text that it encounters in the EPS. As a result, I think that I need something that uses the handles fonts using the Mac OS X Carbon or Cocoa APIs.

If anyone has any ideas or links, please let me know.

Thanks,

Patrick
Back to top
OPENSTEP
The One
The One


Joined: May 25, 2003
Posts: 4752
Location: Santa Barbara, CA

PostPosted: Thu Sep 11, 2003 11:46 pm    Post subject:

Well, I know of a Panther API that could be helpful...but probably is not the kind of dependency you're looking for Wink

There are older versions of ghostscript that function under classic Mac OS APIs:

http://www.cs.wisc.edu/~ghost/macos/index.htm

I suspect portions of them could work directly under Carbon without any X11 dependencies for bitmap generation. The old macgsview can definitely render EPS into TIFFs and other bitmaps as I use it as my standard conversion tool (still, even though it's Classic only), so hopefully it could provide some answers.

ed
Back to top
Terry Teague
Guest





PostPosted: Fri Sep 12, 2003 2:59 am    Post subject: Re: Looking for APIs to convert PostScript to JPEG, GIF, or

pluby wrote:
Unfortunately, Java does supportn reading PostScript into an image. So, the next best alternative would be to convert the EPS to one of the image formats supported by Java: JPEG, GIF, or PNG.

I'm not a graphics person, but I don't think you could go wrong with starting with the following link, and see where it leads you. ImageMagick is a well-known, well-respected cross-platform solution for these kinds of problems. I'm sure there are plenty of other open source libraries out there for the choosing.

http://www.imagemagick.org/

Hope this helps.

Regards, Terry
Back to top
Max_Barel
Oracle


Joined: May 31, 2003
Posts: 219
Location: French Alps

PostPosted: Sat Sep 13, 2003 8:58 am    Post subject: Forget it !

I feel bad to be negative because I'm the one who asked for EPS support in NJ, but I don't think this is worthwhile.
If you convert vectorized EPS to bitmap in the printing process, the EPS benefits -sacalability (giving smooth print), compactness- are lost. The user can do this conversion by himself. It's not worth the work of writing a conversion program. I thought that, since OS X use PDF it could be possible to forward the EPS code to the final PDF. Both are PostScript after all!
If this is not possible, my thinking is that you better use your precious time on other issues.
Back to top
pluby
The Architect
The Architect


Joined: Jun 16, 2003
Posts: 11949

PostPosted: Sat Sep 13, 2003 11:18 am    Post subject: Re: Forget it !

Max_Barel wrote:
I feel bad to be negative because I'm the one who asked for EPS support in NJ, but I don't think this is worthwhile.


Don't fee bad. EPS support is a standrad OOo feature so at some point I need to figure out some way to implement it. Maybe not by the next release, but at least sometime in the near future.

Max_Barel wrote:
If you convert vectorized EPS to bitmap in the printing process, the EPS benefits -sacalability (giving smooth print), compactness- are lost. The user can do this conversion by himself. It's not worth the work of writing a conversion program. I thought that, since OS X use PDF it could be possible to forward the EPS code to the final PDF. Both are PostScript after all!
If this is not possible, my thinking is that you better use your precious time on other issues.


I agree that it is a waste of precious time to write a conversion program. Using a conversion program was, at best, a fallback option to provide EPS support while I kept searching for a way to do what I really wanted to do: pass the EPS directly to the printer like OOo does on Windows and other Unix platforms.

There is good news: passing EPS directly to the printer may actually be feasible. I spent a few minutes this morning using the javap command to decompile Apple's Java print job code and it appears that the Carbon PMPrintSession pointer is accessible (although it is a private data member). Since I use Java Native Interface (JNI) to invoke Java, in theory I can do the following:

- Bypass the private setting on this data member to get a handle to the native PMPrintSession pointer
- Invoke the Carbon PMSessionPostScriptBegin function with the PMPrintSession pointer
- Invoke the Carbon PMSessionPostScriptData function with the EPS data
- Invoke the Carbon PMSessionPostScriptEnd function to switch flush the data to the printer

Does anyone see any complications with this approach? Implementing the above steps is fairly simple, but I am not familiar with Carbon printing so let me know if my approach makes no sense.

Patrick
Back to top
OPENSTEP
The One
The One


Joined: May 25, 2003
Posts: 4752
Location: Santa Barbara, CA

PostPosted: Sun Sep 14, 2003 11:42 am    Post subject:

I believe that's the recommended way to try to feed PostScript directly to a printer with the Carbon APIs. It's not supported for all print drivers, IIRC...e.g. it doesn't contain a rasterizer for non-postscript printers. But it should definitely function for laserwriter drivers and other PS printers Smile

FWIW, there's a potential solution to this with Panther's additional printer support. I can discuss ideas offline (the APIs are still under WWDC NDA and may not make it into the final).

OTOH, doesn't OOo support importing SVG? Another idea may be to try to find a way to quickly convert EPS into SVG and embed them as draw components or something.

ed
Back to top
pluby
The Architect
The Architect


Joined: Jun 16, 2003
Posts: 11949

PostPosted: Thu Sep 18, 2003 9:44 am    Post subject:

Max,

In the "printtest5" patch that I posted this morning (see the NeoOffice/J Testing forum for download instructions), I implemented the Carbon printing APIs that send PostScript to the printer.

I don't have a PostScript printer so I could not test this new code. Can you try it out and let me know if it works? Note that this code, if it works at all, will only work when printing to a real printer. Printing to PDF will not work as the Carbon printing APIs don't seem to support embedding of EPS into PDF output.

Patrick
Back to top
Max_Barel
Oracle


Joined: May 31, 2003
Posts: 219
Location: French Alps

PostPosted: Fri Sep 19, 2003 4:15 am    Post subject:

pluby wrote:

I don't have a PostScript printer so I could not test this new code. Can you try it out and let me know if it works? Note that this code, if it works at all, will only work when printing to a real printer. Printing to PDF will not work as the Carbon printing APIs don't seem to support embedding of EPS into PDF output.

Patrick,
I'm afraid I don't have a personal PS printer either. And it may take some time before I have opportunity to test to a real printer.
Nevertheless, I have a fake PS printer declared in my print center (using instruction from Apple to do it), giving the ability to generate PS (besides PDF) files from the print dialog.
AFAICT, it does not seem to work. EPS image does not display (using a PS viewer). I found no trace of the embedded EPS code in the generated PS file source.

Once again thank you, and congratulations for your work.

Max
Back to top
pluby
The Architect
The Architect


Joined: Jun 16, 2003
Posts: 11949

PostPosted: Fri Sep 19, 2003 8:54 am    Post subject:

Max,

I tried the same thing that you tried: I added a fake Apple printer and then, when printing, selected Print to File -> PostScript. What happens in this case is that the PMSessionPostScriptBegin() function returns a "General Error" error code which is, I think, Carbon's way of saying "this is not a PostScript enabled printer".

From reading the Carbon printing documentation, it appears that I need to invoke the PMSessionSetDocumentFormatGeneration() function and set the spooling format to "PICT+PS" right after Java starts the first print page.

Does anyone with Carbon printing experience have any other ideas?

Patrick
Back to top
Display posts from previous:   
   NeoOffice Forum Index -> NeoOffice Development All times are GMT - 7 Hours
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © Planamesa Inc.
NeoOffice is a registered trademark of Planamesa Inc. and may not be used without permission.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.