Effects are an operation which can be applied to images. They include common and useful functions like blur and sharpen filters.




Effects are applied using the EffectOperation class. To apply an effect you can use code as simple as this.

void function() {
  using (Doc doc = new Doc()) {
    AddImagePage(doc, img5);
    using (ImageLayer layer = AddImagePage(doc, img5)) {
      using (EffectOperation effect = new EffectOperation("Sharpen")) {

[Visual Basic]
Sub ...
  Using doc As New Doc()
    AddImagePage(doc, img5)
    Using layer As ImageLayer = AddImagePage(doc, img5)
      Using effect As New EffectOperation("Sharpen")
      End Using
    End Using
End Sub




The examples make use of a function named AddImagePage. This function simply creates an appropriate Doc object, adds the image and returns the ImageLayer which was added.

private ImageLayer AddImagePage(Doc doc, string path) {
  using (XImage img = XImage.FromFile(path, null)) {
    doc.MediaBox.SetSides(0, 0, img.Width, img.Height);
    doc.Page = doc.AddPage();
    doc.Rect.String = doc.MediaBox.String;
    int id = doc.AddImageObject(img);
    return (ImageLayer)doc.ObjectSoup[id];

[Visual Basic]
Private Function AddImagePage(doc As Doc, path As String) As ImageLayer
  Using img As XImage = XImage.FromFile(path, Nothing)
    doc.MediaBox.SetSides(0, 0, img.Width, img.Height)
    doc.Page = doc.AddPage()
    doc.Rect.[String] = doc.MediaBox.[String]
    Dim id As Integer = doc.AddImageObject(img)
    Return DirectCast(doc.ObjectSoup(id), ImageLayer)
  End Using
End Function