Hi Werner,

First, i1 is the stream number of the main stream (obtained from plgstrm) and 
i2 is another (different) number  obtained from plmkstrm.

Further, according to the docu, plmkstrm switches automatically to the new 
stream. But I can try. I assume you mean plend1, as this one ends the current 
stream and plend stop the complete package.

Ok, I tried to add plsstrm but that did not help.

Regards,
Hans Rijneke.

Shell International Exploration and Production B.V.
The Hague, The Netherlands - Trade Register no. 27002688
Address: Kessler Park 1, 2280 GS  Rijswijk, The Netherlands

(: +31 070 447 2737
*: <mailto:[EMAIL PROTECTED]>
6: <http://www.shell.com/eandp-en>

Disclaimer of Liability: 
This message, any attachment and response string are confidential and may be 
legally  privileged. It is intended only for the use of the parties to  whom it 
is addressed. If you are not the addressee indicated  in this message please 
notify the sender immediately by reply  email and destroy this message.
All information and  attachments remain the property of Shell


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Werner
Smekal
Sent: woensdag 30 januari 2008 13:33
To: plplot-general@lists.sourceforge.net
Subject: Re: [Plplot-general] Segmentation violation


Hi Hans,

I'm working on a similar thing for the wxwidgets driver, and one driver 
which has this already implemented is the tk driver, or more 
specifically the tk bindings. In the file bindings/tk/plframe.c you'll 
find the following code snippet:

/*--------------------------------------------------------------------------*\
  * Save
  *
  * Processes "save" widget command.
  * Saves plot to a file.
\*--------------------------------------------------------------------------*/

static int
Save(Tcl_Interp *interp, register PlFrame *plFramePtr,
      int argc, const char **argv)
{
     int length;
     char c;
     FILE *sfile;

  /* removed some code ...........  */

/* save to specified device & file */

     if ((c == 'a') && (strncmp(argv[0], "as", length) == 0)) {
        if (argc < 3) {
            Tcl_AppendResult(interp, "wrong # args: should be \"",
                             " save as device file\"", (char *) NULL);
            return TCL_ERROR;
        }

     /* If save previously in effect, delete old stream */

        if (plFramePtr->ipls_save) {
            plsstrm(plFramePtr->ipls_save);
            plend1();
        }

     /* Create stream for saves to selected device & file */

        plmkstrm(&plFramePtr->ipls_save);
        if (plFramePtr->ipls_save < 0) {
            Tcl_AppendResult(interp, "Error -- cannot create stream",
                             (char *) NULL);
            plFramePtr->ipls_save = 0;
            return TCL_ERROR;
        }

     /* Open file for writes */

        if ((sfile = fopen(argv[2], "wb+")) == NULL) {
            Tcl_AppendResult(interp, "Error -- cannot open file ", argv[2],
                             " for writing", (char *) NULL);
            plFramePtr->ipls_save = 0;
            plend1();
            return TCL_ERROR;
        }

     /* Initialize stream */

        plsdev(argv[1]);
        plsfile(sfile);
     /* Note: many drivers ignore these, needed to preserve the aspect 
ratio */
         plspage( 0., 0., plFramePtr->width, plFramePtr->height, 0, 0 );
        plcpstrm(plFramePtr->ipls, 0);
        pladv(0);

     /* Remake current plot and then switch back to original stream */

        plreplot();
        plflush();
        plsstrm(plFramePtr->ipls);
     }

/* close save file */

     else if ((c == 'c') && (strncmp(argv[0], "close", length) == 0)) {

        if ( ! plFramePtr->ipls_save) {
            Tcl_AppendResult(interp, "Error -- no current save file",
                             (char *) NULL);
            return TCL_ERROR;
        }
        else {
            plsstrm(plFramePtr->ipls_save);
            plend1();
            plFramePtr->ipls_save = 0;
            plsstrm(plFramePtr->ipls);
        }
     }

/* unrecognized */

     else {
        Tcl_AppendResult(interp, "bad option to \"save\": must be ",
         "as or close", (char *) NULL);

        return TCL_ERROR;
     }

     return TCL_OK;
}

At first look, you doing the right thing, maybe it helps if you try to 
set the stream with plsstrm right before plend(). Wouldn't know why this 
is necessary, but try it. plend should only end the current stream. Do 
i1 and i2 contain different integers or the same?

HTH,
Werner



[EMAIL PROTECTED] wrote:
> Dear All,
> 
> I like to save some pictures as are currently displayed on the screen 
> into a "jpeg" file and then continue with plotting to the screen.
> 
> I tried to do it as follows :
> 
>       call plgstrm(i1)
>       call plmkstrm(i2)
>       call plsfnam('tmp.jpg')
>       call plsdev('jpeg')
>       call plcpstrm(i1,.false.)
>       call plreplot
>       call plend1
>       call plsstrm(i1)
> 
> But as soon as I start plotting again the program crashes with a 
> segmentation violation.
> 
> Using "valgrind" on this, it looks like "plend1" frees the plot buffer 
> of the main stream. Removing "plend1" indeed let me continuing plotting, 
> but then at the end, the call to "plend" gives me errors from "glibc" 
> about corrupted links. Moreover by not calling "plend1" I think a lot of 
> memory will be wasted.
> 
> Is the way as described above for creating an intermediate "jpeg" file 
> valid or do I have to follow another route ?
> 
> Any help is appreciated.
> 
> Thanks,
> Hans Rijneke.
> 
> Shell International Exploration and Production B.V.
> The Hague, The Netherlands - Trade Register no. 27002688
> Address: Kessler Park 1, 2280 GS  Rijswijk, The Netherlands
> 
> (***:* +31 070 447 2737
> ****:_ __<mailto:[EMAIL PROTECTED]>_*
> *6:**__*_____ <http://www.shell.com/eandp-en>_
> 
> */Disclaimer of Liability: /*
> */This message, any attachment and response string are confidential and 
> may be legally  privileged. It is intended only for the use of the 
> parties to  whom it is addressed. If you are not the addressee 
> indicated  in this message please notify the sender immediately by 
> reply  email and destroy this message./*
> 
> */All information and  attachments remain the property of Shell/**//*//
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Plplot-general mailing list
> Plplot-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/plplot-general


-- 
Dr. Werner Smekal
Institut fuer Allgemeine Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria

email: [EMAIL PROTECTED]
web:   http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office)
        +43-(0)1-58801-13469 (laboratory)
fax:   +43-(0)1-58801-13499

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Plplot-general mailing list
Plplot-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-general



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Plplot-general mailing list
Plplot-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-general

Reply via email to