---
title: "GifWriter..::.BasisOptimizationFrameCount Property "
canonical: https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifWriter_BasisOptimizationFrameCount.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# GifWriter.BasisOptimizationFrameCount Property 
 
Gets/sets the number of frames that will be stored before the global palette will be saved.
 
**Namespace:** [Aurigma.GraphicsMill.Codecs](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Codecs.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
Public Property BasisOptimizationFrameCount As Integer
```
 
```csharp
public int BasisOptimizationFrameCount { get; set; }
```
 
### Property Value
Number of frames to store. If this value is `-1`, there is no limit for the number of frames used to build a global palette for.
 
## Remarks
  
If the optimization is enabled (the [Optimized](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifWriter_Optimized.htm.md) property is set to **true**), Graphics Mill for .NET will try to build a global palette which is common for all frames (other optimization activities are done as well, but they do not concern this property). Due a GIF format specification, no image data may be written before the global palette is saved. Therefore we cannot write a frame as soon as the [AddFrame(IFrame)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_FormatWriter_AddFrame_1_7fae152b.htm.md) method is called. Instead of it we should store the frame in memory before the global palette will be generated and saved to the memory. Frames will be saved to the file only when the writer is closed.
 
Obviously, if you add too many frames, it will consume too much memory. To avoid this, use this value to specify a threshold for the number of frames to build a global palette for.
 
Another way to stop gathering statistics for the global palette is to set the [LastFrame](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifFrame_LastFrame.htm.md) property to **true** on the frame we would like to stop. In this case the BasisOptimizationFrameCount will be disregarded.
 
If you add some frames after global palette is generated, and all entries of palettes of these frames are the same as in the global palette, Graphics Mill for .NET automatically uses the global palette. However if at least one color will not be contained in the global palette, this frame will be saved with a local palette.
   
## See Also

### Reference

- [GifWriter Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_GifWriter.htm.md)
- [Aurigma.GraphicsMill.Codecs Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Codecs.htm.md)
- [GifWriter.Optimized](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifWriter_Optimized.htm.md)
- [GifFrame.LastFrame](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifFrame_LastFrame.htm.md)
