Click or drag to resize

AtalaImageChangePixelFormat Event

Occurs when the image data changes PixelFormats.

Namespace:  Atalasoft.Imaging
Assembly:  Atalasoft.dotImage (in Atalasoft.dotImage.dll) Version: (.NET 4.5.2, x86)
public static event PixelFormatChangeEventHandler ChangePixelFormat


Type: Atalasoft.ImagingPixelFormatChangeEventHandler
This static event is usually fired when a particular method is not compatible with the current PixelFormat and it needs to be changed. By handling this event, you may show a dialog to the user that the current PixelFormat will be changed and allow that operation to be cancelled by setting the Cancel property in the PixelFormatChangeEventArgs to true.
ChangePixelFormat Example (C#)
// Setup the event handler.
AtalaImage.ChangePixelFormat += new PixelFormatChangeEventHandler(OnPixelFormatChange);

// Force the handler to cancel the operation.
AtalaImage image = new AtalaImage(@"D:\Test Images\1.jpg");
AtalaImage gray = image.GetChangedPixelFormat(PixelFormat.Pixel8bppGrayscale, null, true);

if (gray != null)

private void OnPixelFormatChange(object sender, PixelFormatChangeEventArgs e)
    // Don't allow a 24-bit image to be converted to 8-bit grayscale.
    if (e.CurrentPixelFormat == PixelFormat.Pixel24bppBgr && e.NewPixelFormat == PixelFormat.Pixel8bppGrayscale)
        e.Cancel = true;
ChangePixelFormat Example (Visual Basic)
Private  Sub OnPixelFormatChange(ByVal sender As Object, ByVal e As PixelFormatChangeEventArgs) Handles AtalaImage.ChangePixelFormat
    ' Don't allow a 24-bit image to be converted to 8-bit grayscale.
    If e.CurrentPixelFormat = PixelFormat.Pixel24bppBgr And e.NewPixelFormat = PixelFormat.Pixel8bppGrayscale Then
        e.Cancel = True
    End If
End Sub

' Force the handler to cancel the operation.
Dim image As AtalaImage =  New AtalaImage("D:\Test Images\1.jpg") 
Dim gray As AtalaImage =  image.GetChangedPixelFormat(PixelFormat.Pixel8bppGrayscale, Nothing, True) 

If Not gray Is Nothing Then
End If
See Also