CIRandomGenerator Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A CIFilter whose pixels are randomly colored.
public class CIRandomGenerator : CoreImage.CIFilter, CoreImage.ICIRandomGeneratorProtocol, IDisposable
type CIRandomGenerator = class
inherit CIFilter
interface ICIRandomGeneratorProtocol
interface INativeObject
interface IDisposable
interface ICIFilterProtocol
- Inheritance
- Implements
Remarks
The CIRandomGenerator is idempotent: it always returns the same data. To retrieve a different random pattern, developers must retrieve the data from a random offset. For instance:
GKRandomSource src = MyRandomSource; // Initialized previously
var locX = (int)(src.GetNextUniform() * extent - size.Width);
var locY = (int)(src.GetNextUniform() * extent - size.Height);
CIImage img = randomGenerator.OutputImage.ImageByCroppingToRect(new CGRect(locX, locY, size.Width, size.Height));
var xlat = CGAffineTransform.MakeTranslation(-locX, -locY);
CIImage finalImg = img.ImageByApplyingTransform(xlat);
Each of the color components is independently uniformly distributed.
The following example shows this filter in use:
// Create a CIRandomGenerator filter with the input image
var random_generator = new CIRandomGenerator ();
// Get the altered image from the filter
var output = new CICrop {
Image = random_generator.OutputImage,
Rectangle = new CIVector (0, 0, 400, 300)
}.OutputImage;
// To render the results, we need to create a context, and then
// use one of the context rendering APIs, in this case, we render the
// result into a CoreGraphics image, which is merely a useful representation
//
var context = CIContext.FromOptions (null);
var cgimage = context.CreateCGImage (output, output.Extent);
// The above cgimage can be added to a screen view, for example, this
// would add it to a UIImageView on the screen:
myImageView.Image = UIImage.FromImage (cgimage);
Produces the following output:

Constructors
| Name | Description |
|---|---|
| CIRandomGenerator() |
Creates a new CIRandomGenerator with default values. |
| CIRandomGenerator(NativeHandle) |
A constructor used when creating managed representations of unmanaged objects. Called by the runtime. |
| CIRandomGenerator(NSCoder) |
A constructor that initializes the object from the data stored in the unarchiver object. |
| CIRandomGenerator(NSObjectFlag) |
Constructor to call on derived classes to skip initialization and merely allocate the object. |
Properties
| Name | Description |
|---|---|
| AccessibilityAttributedUserInputLabels | (Inherited from NSObject) |
| AccessibilityRespondsToUserInteraction | (Inherited from NSObject) |
| AccessibilityTextualContext | (Inherited from NSObject) |
| AccessibilityUserInputLabels | (Inherited from NSObject) |
| Attributes |
Configurable attributes of the filter. (Inherited from CIFilter) |
| Class | (Inherited from NSObject) |
| ClassHandle |
The Objective-C class handle for this class. (Inherited from CIFilter) |
| DebugDescription | (Inherited from NSObject) |
| Description | (Inherited from NSObject) |
| ExposedBindings | (Inherited from NSObject) |
| Handle |
Handle (pointer) to the unmanaged object representation. (Inherited from NSObject) |
| InputKeys |
Gets an array that contains the names of the input keys for the filter. (Inherited from CIFilter) |
| IsDirectBinding | (Inherited from NSObject) |
| IsProxy | (Inherited from NSObject) |
| Item[NSString] |
Gets the value that is identified by |
| Name |
Gets the filter name. (Inherited from CIFilter) |
| OutputImage | |
| OutputKeys |
Gets an array that contains the names of the output keys for the filter. (Inherited from CIFilter) |
| RetainCount | (Inherited from NSObject) |
| Self | (Inherited from NSObject) |
| Superclass | (Inherited from NSObject) |
| SuperHandle |
Handle used to represent the methods in the base class for this NSObject. (Inherited from NSObject) |
| Zone | (Inherited from NSObject) |