---
title: "CustomFormatWriter..::.GetClosestPixelFormat Method "
canonical: https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_CustomFormatWriter_GetClosestPixelFormat_1_3e209c07.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/)

# CustomFormatWriter.GetClosestPixelFormat Method 
 
Get a pixel format supported by this writer closest to the specified one.
 
**Namespace:** [Aurigma.GraphicsMill.Codecs](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Codecs.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
Protected Friend MustOverride Function GetClosestPixelFormat ( _pixelFormat As PixelFormat _
) As PixelFormat
```
 
```csharp
protected internal abstract PixelFormat GetClosestPixelFormat(PixelFormat pixelFormat
)
```
 
### Parameters
 
 - pixelFormat
     - Type: [Aurigma.GraphicsMill.PixelFormat](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_PixelFormat.htm.md)
 [PixelFormat](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_PixelFormat.htm.md) enumeration member that specifies the pixel format you would like to get a closest pixel format of this codec for.
 
### Return Value
 [PixelFormat](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_PixelFormat.htm.md) enumeration member that specifies the closest pixel format supported by the writer comparing to the specified one.
 
## Remarks
  
This method is used to automate conversion of the bitmap before saving it.
 
Imagine, that your file format supports only 24-bit RGB and 32-bit CMYK. If the user tries to save, say, 8-bit indexed image, obviously you should convert it to 24-bit RGB. But for 40-bit ACMYK bitmap, you should convert to 32-bit CMYK (to avoid color losses during conversion between CMYK and RGB).
 
## Examples
  
```csharp
protected override PixelFormat GetClosestPixelFormat(PixelFormat pixelFormat)
{
    PixelFormat closestFormat;
    
    //...Select the format based on some criteria and assign the result to the
    //closestFormat variable...
    
    return closestFormat;
}
```
   
## See Also

### Reference

- [CustomFormatWriter Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_CustomFormatWriter.htm.md)
- [Aurigma.GraphicsMill.Codecs Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Codecs.htm.md)
