> Even though the data pointed to by ImagePointer is read and write, you should
> not attempt to write or modify in any way. Anything dangerous you do with the
> pointer and the data pointed to is your responsibility.
## Writing Image Files
You can write any image file using `StbImage.WritePng`/`WriteBmp`/`WriteTga`/`WriteHdr` and `WriteJpg` functions. These will take a span, a stream and information about the format of
the image.
If your wish is to write an `StbImage` instance back to disk, you can use the instance
functions of the same name.
```cs
using Stream stream;
StbImage.WritePng(pixels, width, height, format, stream, isFloat);
StbImage.WriteBmp(pixels, width, height, format, stream, isFloat);
StbImage.WriteTga(pixels, width, height, format, stream, isFloat);
StbImage.WriteHdr(pixels, width, height, format, stream, isFloat);
StbImage.WriteJpg(pixels, width, height, format, stream, quality, isFloat);
StbImage image;
image.WritePng(stream);
image.WriteBmp(stream);
image.WriteTga(stream);
image.WriteHdr(stream);
image.WriteJpg(stream, quality);
```
> [!WARNING]
> These funtions depend on non-thread safe global options. Even though the
> functions themselves are reentrant, it might require some synchronization.
> This is a limitation of `stb_image_write` rather than `ReFuel.StbImage`.
| `bool StbImage.FlipVerticallyOnLoad { set; }` | Flips the image vertically after loading. Practical for uses where a right handed coordinate system is used (e.g. OpenGL) |
| `bool StbImage.FlipVerticallyOnSave { set; }` | Similar to FlipVerticallyOnLoad, it will flip
the image vertically when writing. |
| `bool StbImage.UnpremultiplyOnLoad { set; }` | Applies to Apple iPhone PNG images, where the image is sometimes encoded with premultiplied alpha. Reverses this premultiplication. |
| `int StbImage.WriteForcePngFilter { get; set; }` | Forces a filter when writing PNG images. Must be -1 for auto, or 0 through 5, higher is more. See STBI documentation. |
| `int WritePngCompressionLevel { get; set; }` | Changes the PNG deflate compression level. Higher is more. Higher values take longer. 8 by default. |
| `bool WriteTgaEnableRLE { get; set; }` | Enables run length encoding for TGA images when writing. |
If you wish to call the native Stbi library, call functions in the static class `ReFuel.Stb.Native.Stbi`. See `stb_image.h` and `stb_image_write.h` documentation [online](https://github.com/nothings/stb/blob/master/stb_image.h).