ImageFilter

class ImageFilter

Base class for image filters.

If one is installed in the paint, then all drawing occurs as usual, but it is as if the drawing happened into an offscreen (before the xfermode is applied). This offscreen bitmap will then be handed to the imagefilter, who in turn creates a new bitmap which is what will finally be drawn to the device (using the original xfermode).

The local space of image filters matches the local space of the drawn geometry. For instance if there is rotation on the canvas, the blur will be computed along those rotated axes and not in the device space. In order to achieve this result, the actual drawing of the geometry may happen in an unrotated coordinate system so that the filtered image can be computed more easily, and then it will be post transformed to match what would have been produced if the geometry were drawn with the total canvas matrix to begin with.

See ImageFilters for available filters.

Subclasses

ImageFilters

Classes

CropRect

MapDirection

Members:

Type

Members:

Methods

Deserialize

__init__

asAColorFilter

Returns colorfilter if this imagefilter can be completely replaced by the returned colorfilter.

asColorFilter

canComputeFastBounds

computeFastBounds

countInputs

Returns the number of inputs this filter will accept (some inputs can be NULL).

filterBounds

Map a device-space rect recursively forward or backward through the filter DAG.

getFlattenableType

getInput

Returns the input filter at a given index, or NULL if no input is connected.

getTypeName

Returns the name of the object's class.

isColorFilterNode

Returns ColorFilter if it can.

makeWithLocalMatrix

If this filter can be represented by another filter + a localMatrix, return that filter, else return null.

ref

Increment the reference count.

serialize

unique

May return true if the caller is the only owner.

unref

Decrement the reference count.

Attributes

kColorFilter_Type

kDrawLooper_Type

kDrawable_Type

kForward_MapDirection

kImageFilter_Type

kMaskFilter_Type

kPathEffect_Type

kReverse_MapDirection

Methods

static ImageFilter.Deserialize(data: buffer) skia.ImageFilter
ImageFilter.__init__(*args, **kwargs)
ImageFilter.asAColorFilter(self: skia.ImageFilter) object

Returns colorfilter if this imagefilter can be completely replaced by the returned colorfilter. Otherwise None.

i.e. the two effects will affect drawing in the same way.

ImageFilter.asColorFilter(self: skia.ImageFilter) object
ImageFilter.canComputeFastBounds(self: skia.ImageFilter) bool
ImageFilter.computeFastBounds(self: skia.ImageFilter, bounds: skia.Rect) skia.Rect
ImageFilter.countInputs(self: skia.ImageFilter) int

Returns the number of inputs this filter will accept (some inputs can be NULL).

ImageFilter.filterBounds(self: skia.ImageFilter, src: skia.IRect, ctm: skia.Matrix, direction: skia.ImageFilter.MapDirection, inputRect: skia.IRect = None) skia.IRect

Map a device-space rect recursively forward or backward through the filter DAG.

kForward_MapDirection is used to determine which pixels of the destination canvas a source image rect would touch after filtering. kReverse_MapDirection is used to determine which rect of the source image would be required to fill the given rect (typically, clip bounds). Used for clipping and temp-buffer allocations, so the result need not be exact, but should never be smaller than the real answer. The default implementation recursively unions all input bounds, or returns the source rect if no inputs.

In kReverse mode, ‘inputRect’ is the device-space bounds of the input pixels. In kForward mode it should always be null. If ‘inputRect’ is null in kReverse mode the resulting answer may be incorrect.

ImageFilter.getFlattenableType(self: skia.Flattanable) skia.Flattanable.Type
ImageFilter.getInput(self: skia.ImageFilter, i: int) skia.ImageFilter

Returns the input filter at a given index, or NULL if no input is connected.

The indices used are filter-specific.

ImageFilter.getTypeName(self: skia.Flattanable) str

Returns the name of the object’s class.

Implemented in Drawable.

ImageFilter.isColorFilterNode(self: skia.ImageFilter) object

Returns ColorFilter if it can. Otherwise returns None.

ImageFilter.makeWithLocalMatrix(self: skia.ImageFilter, matrix: skia.Matrix) skia.ImageFilter

If this filter can be represented by another filter + a localMatrix, return that filter, else return null.

ImageFilter.ref(self: skia.RefCntBase) None

Increment the reference count.

Must be balanced by a call to unref().

ImageFilter.serialize(self: skia.Flattanable) skia.Data
ImageFilter.unique(self: skia.RefCntBase) bool

May return true if the caller is the only owner.

Ensures that all previous owner’s actions are complete.

ImageFilter.unref(self: skia.RefCntBase) None

Decrement the reference count.

If the reference count is 1 before the decrement, then delete the object. Note that if this is the case, then the object needs to have been allocated via new, and not on the stack.

Attributes

ImageFilter.kColorFilter_Type = <Type.kColorFilter_Type: 0>
ImageFilter.kDrawLooper_Type = <Type.kDrawLooper_Type: 3>
ImageFilter.kDrawable_Type = <Type.kDrawable_Type: 2>
ImageFilter.kForward_MapDirection = <MapDirection.kForward_MapDirection: 0>
ImageFilter.kImageFilter_Type = <Type.kImageFilter_Type: 4>
ImageFilter.kMaskFilter_Type = <Type.kMaskFilter_Type: 5>
ImageFilter.kPathEffect_Type = <Type.kPathEffect_Type: 6>
ImageFilter.kReverse_MapDirection = <MapDirection.kReverse_MapDirection: 1>