Skip to main content
`Ctrl`+`K`

# PetscDrawSetSave

Saves images produced in a `PetscDraw` into a file

## Synopsis

    #include "petscdraw.h"
    PetscErrorCode PetscDrawSetSave(PetscDraw draw, const char filename[])

Collective

## Input Parameters

- draw - the graphics context

- filename - name of the file, if .ext then uses name of draw object plus .ext using .ext to determine the image type

## Options Database Keys

- -draw_save <filename> - filename could be name.ext or .ext (where .ext determines the type of graphics file to save, for example .png)

- -draw_save_final_image [optional filename] - saves the final image displayed in a window

- -draw_save_single_file - saves each new image in the same file, normally each new image is saved in a new file with filename/filename_%d.ext

## Note

You should call this BEFORE creating your image and calling `PetscDrawSave()`. The supported image types are .png, .gif, .jpg, and .ppm (PETSc chooses the default in that order). Support for .png images requires configure –with-libpng. Support for .gif images requires configure –with-giflib. Support for .jpg images requires configure –with-libjpeg. Support for .ppm images is built-in. The PPM format has no compression (640x480 pixels ~ 900 KiB).

## See Also

`PetscDraw`, `PetscDrawOpenX()`, `PetscDrawOpenImage()`, `PetscDrawSetFromOptions()`, `PetscDrawCreate()`, `PetscDrawDestroy()`, `PetscDrawSetSaveFinalImage()`

## Level

intermediate

## Location

src/sys/classes/draw/interface/dsave.c

Index of all Draw routines
Table of Contents for all manual pages
Index of all manual pages