ImageView

The ImageView allows changing induvidual pixels with the slicing and indexing operators.

1 ImageView view = image.view();
2 
3 //Assign a square.
4 view[4..40][5..50] = new Color("red");
5 
6 //Reduce a view.
7 view = view[10..view.extend.height-10][20..view.extend.width-20];
8 
9 //Assign a single row.
10 view[30] = new Color("blue");
11 //Or a column.
12 view[][30] = new Color("blue");
13 //And induvidual pixels.
14 view[3][5] = new Color("green");
15 
16 //We can also use foreach.
17 foreach ( row; view )
18 {
19    //This is executed in parallel.
20    foreach ( ref pixel; row )
21        pixel = new Color("black");
22 }

Constructors

this
this(Image image, Geometry area)

Create a new view for image.

Members

Functions

opApply
int opApply(int delegate(Pixels) dg)

Support the usage of foreach to loop over the rows in the view. The foreach is executed in parallel.

opDollar
size_t opDollar()

The height or the width of the view, depending on in which slice it's used.

opIndex
Pixels opIndex(size_t row)
opIndexAssign
void opIndexAssign(Color color, size_t index)

Indexing operators yield or modify the value at a specified index.

opSlice
ImageView opSlice()
ImageView opSlice(size_t upper, size_t lower)
opSliceAssign
void opSliceAssign(Color color)
void opSliceAssign(Color color, size_t upper, size_t lower)

Sliceing operators yield or modify the value in the specified slice.

Properties

height
size_t height [@property getter]

The height of the view.

width
size_t width [@property getter]

The width of the view.

Meta