... | ... | @@ -71,7 +71,7 @@ Each filter in a filter chain, is described by the filter name, a render destina |
|
|
|
|
|
In the above json example, the core image filter to be created is a Core Image Unsharp Mask filter. The filter is given the identifier "com.yvs.renderingfilterchain.example.unsharpmask" and the filter takes three inputs. These are the input radius, which takes a numeric value, input intensity which also takes a numeric value the input image which of course takes an image.
|
|
|
|
|
|
When an input is an image, then the input value is a way to obtain the image and is a json object. The image can be sourced as the output image of a previous filter in the filter chain and if that was the case then the key in the object would be "mifiltername" and the value would be a string which is the name identifier. If the image is sourced from a bitmap context then the key in the object would be "objectreference" as in the above example which refers to a base object with reference 0. The image can also come from an image importer object in which case the "objectreference" key is also used but that a "imageindex" key should also be supplied specifying the index of the image in the image file. If "imageindex" is not specified and the object reference refers to an image importer object then "imageindex" defaults to 0.
|
|
|
When an input is an image, then the input value is a way to obtain the image and is a json object. The image can be sourced as the output image of a previous filter in the filter chain and if that was the case then the key in the object would be "cifilterindex" and the value is an index to an earlier filter in the filter chain or a key "mifiltername" and the value would be a string which is the name identifier. If the image is sourced from a bitmap context then the key in the object would be "objectreference" as in the above example which refers to a base object with reference 0. The image can also come from an image importer object in which case the "objectreference" key is also used but that a "imageindex" key should also be supplied specifying the index of the image in the image file. If "imageindex" is not specified and the object reference refers to an image importer object then "imageindex" defaults to 0.
|
|
|
|
|
|
When a filter takes a numeric input, then the "cifiltervalueclass" key is not needed but for all other input types specifying the value class is required and in the above example "CIImage" is demonstrated. Other "cifiltervalueclass" keys are "CIVector", "CIColor", "NSString". In the case of both CIVector and CIColor the type of the value for the key "cifiltervalue" is a string, the purpose of the "cifiltervalueclass" key is to inform Moving Images what object type the string needs to be converted into before it can be assigned to the filter.
|
|
|
|
... | ... | @@ -109,7 +109,132 @@ 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.
|
|
|
|
|
|
{
|
|
|
"cirenderdestination": {
|
|
|
"objectreference": 5
|
|
|
},
|
|
|
"cifilterlist": [
|
|
|
{
|
|
|
"cifiltername": "CIRadialGradient",
|
|
|
"mifiltername": "radialfilter",
|
|
|
"cifilterproperties": [
|
|
|
{
|
|
|
"cifilterkey": "inputCenter",
|
|
|
"cifiltervalueclass": "CIVector",
|
|
|
"cifiltervalue": "[200.0 200.0]"
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputRadius0",
|
|
|
"cifiltervalue": 10.0
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputRadius1",
|
|
|
"cifiltervalue": 200.0
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputColor0",
|
|
|
"cifiltervalueclass": "CIColor",
|
|
|
"cifiltervalue": "1 1 1 1"
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputColor1",
|
|
|
"cifiltervalueclass": "CIColor",
|
|
|
"cifiltervalue": "0 0 0 1"
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cifiltername": "CICrop",
|
|
|
"mifiltername": "cropfilter",
|
|
|
"cifilterproperties": [
|
|
|
{
|
|
|
"cifilterkey": "inputRectangle",
|
|
|
"cifiltervalue": "[0 0 400.0 400.0]",
|
|
|
"cifiltervalueclass": "CIVector"
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputImage",
|
|
|
"cifiltervalueclass": "CIImage",
|
|
|
"cifiltervalue": {
|
|
|
"mifiltername": "radialfilter"
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cifiltername": "CIHeightFieldFromMask",
|
|
|
"mifiltername": "heightfieldmask",
|
|
|
"cifilterproperties": [
|
|
|
{
|
|
|
"cifilterkey": "inputImage",
|
|
|
"cifiltervalue": {
|
|
|
"objectreference": 4
|
|
|
},
|
|
|
"cifiltervalueclass": "CIImage"
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputRadius",
|
|
|
"cifiltervalue": 17.0
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cifiltername": "CIShadedMaterial",
|
|
|
"mifiltername": "shadedmaterial",
|
|
|
"cifilterproperties": [
|
|
|
{
|
|
|
"cifilterkey": "inputImage",
|
|
|
"cifiltervalueclass": "CIImage",
|
|
|
"cifiltervalue": {
|
|
|
"mifiltername": "heightfieldmask"
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputScale",
|
|
|
"cifiltervalue": 16.0
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputShadingImage",
|
|
|
"cifiltervalueclass": "CIImage",
|
|
|
"cifiltervalue": {
|
|
|
"mifiltername": "cropfilter"
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cifiltername": "CIBumpDistortion",
|
|
|
"mifiltername": "bumpdistortion",
|
|
|
"cifilterproperties": [
|
|
|
{
|
|
|
"cifilterkey": "inputImage",
|
|
|
"cifiltervalueclass": "CIImage",
|
|
|
"cifiltervalue": {
|
|
|
"mifiltername": "shadedmaterial"
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputScale",
|
|
|
"cifiltervalue": 1.0
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputCenter",
|
|
|
"cifiltervalueclass": "CIVector",
|
|
|
"cifiltervalue": "[227.0 170.5]"
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputRadius",
|
|
|
"cifiltervalue": 250.0
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
|
|
|
The filter graph for the above filter chain.
|
|
|
![Filter Graph](../raw/master/wiki-images/FilterGraph.jpg "The filter graph for the above json object filter chain representation.")
|
|
|
|
|
|
### Providing images from image importer and bitmap context objects
|
|
|
|
... | ... | |