On Tue, Jul 07, 2009 at 11:06:40AM -0400, Hazen Babcock wrote: > Alan W. Irwin wrote: > > On 2009-07-06 12:26-0400 Hazen Babcock wrote: > > > >> Hezekiah M. Carty wrote: > >>> On Sun, Jul 5, 2009 at 9:15 PM, Hazen Babcock<hbabc...@mac.com> wrote: > >>>> As of v10119 you can now specify the color table to use for color table > >>>> 0 or color table 1 as a command line argument to PLplot. For example: > >>>> > >>> <cut> > >>>> As part of this effort the PLplot API has two new additions: > >>>> plspal0(filename) - Set the color table 0 palette based on the > >>>> cmap0.pal > >>>> format file specified by filename. > >>>> plspal1(filename) - Set the color table 1 palette based on the > >>>> cmap1.pal > >>>> format file specified by filename. > >>>> > >>>> Example .pal format files can be found in plplot-source/bindings/tk. > >>>> Hopefully this addition will make it easier for people to use their > >>>> preferred color scheme. > >>> > >>> Hazen, > >>> > >>> Thank you for putting these functions together. Are the names set and > >>> ready to be propagated to other language bindings? > >> > >> I'd wait a week or two to see if anyone complains. > >> > >>> Where should new color palettes be placed in the PLplot source tree? > >> > >> I think that they are going to go into a new directory called cmaps in > >> the root directory. > > > > Hi Hazen: > > > > Much thanks for this effort which is going to make colour management much > > easier for PLplot. > > > > Currently plspal0 and plspal0 simply fopen the specified file with no > > checks > > on whether it exists. One obvious way to deal with that issue is to use > > the > > same function (plLibOpenPdfstrm) we use for opening map files and also our > > traditional Hershey font files. > > > > plLibOpenPdfstrm currently tries a large number of standard locations > > (including the current directory) to find the file specified. > > Any pointers for using this function? When I try: > fp = (FILE *)plLibOpenPdfstrm(filename); > > instead of: > fp = fopen(filename, "r"); > > I get a segmentation fault at my first attempt to read from the file: > fscanf(fp, "%d\n", &number_colors); > > My guess was that this was due to the fact that it opens the file in > "rb" mode instead of "r" mode, but when I modified it to use "r" mode I > still got the same segfault.
Hazen, The "b" is ignored on all POSIX implementations of fopen and is retained only for backwards compatibility. It is (was?) important on windows last time I tried, which was some years ago. If you look at the source, plLibOpenPdfStream returns a PDFstrm pointer not a FILE pointer. You want to use the plLibOpen wrapper function instead. This does return a FILE * and should work as you expect, at least on POSIX / UNIX systems. It might be necessary to modify the functions to allow opening the file in text mode on windows systems. Andrew ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel