... | ... | @@ -109,7 +109,7 @@ In the following example the json object represents the information needed for c |
|
|
|
|
|
### Chaining filters together
|
|
|
|
|
|
The following json object is everything needed to define the filter chain managed by a "imagefilterchain" base object. The render destination is specified using the "cirenderdestination" key, more about the render destination later. The value for the "cifilterlist" key is a list of filter objects each one describing one filter in the filter list. The order of the filters in this list is important, for a few reasons. The outputImage of the last filter in the filter chain is the the one that renders to the render destination. Since you can refer to an earlier filter in the filter chain by its filter index "cifilterindex" then the order needs to be correct or even if you refer to filters by the name identifier you can only refer to filters which have already been defined in the list.
|
|
|
The following json object is everything needed to define the filter chain managed by a "imagefilterchain" base object. The render destination is specified using the "cirenderdestination" key. The value for the "cifilterlist" key is a list of filter objects each one describing one filter in the filter list. The order of the filters in this list is important, for a few reasons. The outputImage of the last filter in the filter chain is the the one that renders to the render destination. Since you can refer to an earlier filter in the filter chain by its filter index "cifilterindex" then the order needs to be correct or even if you refer to filters by the name identifier you can only refer to filters earlier in the list of filters.
|
|
|
|
|
|
{
|
|
|
"cirenderdestination": {
|
... | ... | @@ -253,11 +253,85 @@ After this I took advantage of other features of Moving Images. I generated mult |
|
|
|
|
|
![Bump distortion gif animation](../raw/master/wiki-images/EmbossedBumpDistortionAnimation.gif "An embossed bump distortion image animation.")
|
|
|
|
|
|
### Providing images from image importer and bitmap context objects
|
|
|
### Providing input images
|
|
|
|
|
|
An input image for a filter can come from either the output image of an earlier filter in the filter chain or from an image source from a base object. Both of these ways of supplying an input image to a filter has been demonstrated above.
|
|
|
|
|
|
If you source an input image from an output image of an earlier filter in the filter chain then you can do it in one of two ways:
|
|
|
|
|
|
Method 1 using the name identifier of an earlier filter, in this case the filter supplying the image is one with a name identifier "heightfieldmask".
|
|
|
|
|
|
{
|
|
|
"cifilterkey": "inputImage",
|
|
|
"cifiltervalueclass": "CIImage",
|
|
|
"cifiltervalue": {
|
|
|
"mifiltername": "heightfieldmask"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Method 2 using the filter index in the filter chain of an earlier filter, in this case the filter supplying the image is the first one in the filter chain with index 0.
|
|
|
|
|
|
{
|
|
|
"cifilterkey": "inputImage",
|
|
|
"cifiltervalueclass": "CIImage",
|
|
|
"cifiltervalue": {
|
|
|
"cifilterindex": 0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
If the input image for a filter is from a base object like a bitmap context or a image importer object then the "objectreference" key is required and it's value is a base object reference, or alternatively the two keys "objecttype" and "objectname" are required. The value for the "objecttype" key will be "bitmapcontext" or "imageimporter". The value for the "objectname" is the name of the base object given to it when it was created.
|
|
|
|
|
|
If the base object reference identifies a "imageimporter" object or if the "objecttype" is "imageimporter" then a "imageindex" should also be supplied which refers to the index of the image in the image file. If the "imageindex" key is not supplied then the image index value defaults to 0.
|
|
|
|
|
|
### Rendering an Image Filter Chain object
|
|
|
|
|
|
At present the only object type that can be a render destination is the object type "bitmapcontext". This will change.
|
|
|
At present the only object type that can be a render destination is the object type "bitmapcontext". This will change. The rendering destination is specified as a plist dictionary/JSON object. This object can be defined in one of two ways, by specifying a value for the key "objectreference" which is a reference to the base object that is the destination for the image filter chain render, or by setting the value for the key "objecttype" which for now will be "bitmapcontext" and setting the value for the key "objectname" which is the name given to the base object when it was created. There will be more values for the key "objecttype" than "bitmapcontext" in the future, do not assume that this value will remain invariant.
|
|
|
|
|
|
Render destination example 1:
|
|
|
|
|
|
{
|
|
|
"cirenderdestination": {
|
|
|
"objectreference": 5
|
|
|
},
|
|
|
"cifilterlist": [
|
|
|
{
|
|
|
"cifiltername": "CIRandomGenerator"
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
|
|
|
Render destination example 2:
|
|
|
|
|
|
{
|
|
|
"cirenderdestination": {
|
|
|
"objecttype": "bitmapcontext",
|
|
|
"objectname" : "com.yvs.renderdestination.example2"
|
|
|
},
|
|
|
"cifilterlist": [
|
|
|
{
|
|
|
"cifiltername": "CIRandomGenerator"
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
|
|
|
The render destination is specified as part of the creation of the image filter chain base object.
|
|
|
At render time you can specify filter properties for different filters to modify their values in the "-renderfilterchain" smig "doaction". The render filter chain command can take a json object which has at a minimum a "cifilterproperties" key. The value for this key is an array of objects, each object contains three members. The "mifiltername" key which identifies the filter in the filter chain which has a property whose value you want to change. The other two members have keys "cifilterkey" and "cifiltervalue". The "cifilterkey" specifies the property key of the attribute of the filter you want to change, and the "cifiltervalue" which is the value that you want to assign to the filter property.
|
|
|
|
|
|
{
|
|
|
"cifilterproperties": [
|
|
|
{
|
|
|
"cifilterkey": "inputScale",
|
|
|
"cifiltervalue": -0.03038950130322813,
|
|
|
"mifiltername": "bumpdistortion"
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
|
|
|
The following demonstrates rendering the filter chain after updating the "inputScale" property of the bump distortion filter to -0.0304.
|
|
|
|
|
|
smig doaction -renderfilterchain -object 3 -jsonstring '{"cifilterproperties":[{"cifilterkey":"inputScale","cifiltervalue":-0.0304,"mifiltername":"bumpdistortion"}]}'
|
|
|
|
|
|
XXXX need to add info about specifying the source and destination rectangles.
|
|
|
|
|
|
### The Image Filter Chain ruby processing scripts
|
|
|
|
... | ... | |