TransformOrientation Data Member Function

Rotates or flips a 1-dimensional array by performing the transformation as if the array were 2-dimensional.

Prototype

int32 TransformOrientation( Uint8Iterator first, Uint8Iterator last, Uint8Iterator dst, Int32Array p_aiParams )

Parameters

Parameter Type Parameter Name Documentation
<Uint8Iterator>firstAn iterator at the start of the source range.
<Uint8Iterator>lastAn iterator at the end of the source range.
<Uint8Iterator>dstAn iterator at the end of the destination range.
<Int32Array>p_aiParamsA pointer to an <Int32Array> containing the params for the transformation. This array must contain exactly 5 items. Index 0 = An integer value representing a value from the ImageRotateOptions enum. Index 1 = An integer value representing a value from the ImageFlipOptions enum. Index 2 = The width of the 2D 'view' of the source array. The width * height must match the number of elements in the array. Index 3 = The height of the 2D 'view' of the source array. The width * height must match the number of elements in the array. Index 4 = Zero or one. This option is undocument at present.

Examples

Copy Text To Clipboard

auto Uint8ArrayAlgorithms a_auAlgorithms;

auto Uint8Array src = new Uint8Array( 16, 0 );
auto Uint8ArrayView src_view = src.GetView();
a_auAlgorithms.Iota( src_view.First, src_view.Last, 0 );

auto Uint8Array dst = new Uint8Array( 16, 0 );
auto Uint8ArrayView dst_view = dst.GetView();

auto Int32Array a_aeTransformOptions;
a_aeTransformOptions.Add( Enum.ImageRotateOptions_NoRotation() );
a_aeTransformOptions.Add( Enum.ImageFlipOptions_FlipHeight() );
a_aeTransformOptions.Add( 4 );
a_aeTransformOptions.Add( 4 );
a_aeTransformOptions.Add( 0 );

bool a_bXform = a_auAlgorithms.TransformOrientation(
   src_view.First, src_view.Last, dst_view.First, a_aeTransformOptions );

LibUint8Array.Out2D( src, 4, 4 );
Console.Out( "---" );
LibUint8Array.Out2D( dst, 4, 4 );

// Or for an Image.

// Open an Image from disk. You must specify
// a valid path. The path shown below is
// for example purposes only.
auto Image a_oImage;
a_oImage.OpenFile( "D:\\MyFolder\\in.png" );

// Take a view of the Image.
auto Uint8ArrayView src_view = a_oImage.GetUint8View();

// Query the number of scalars per pixel.
auto ImageFormatQuery a_oQuery;
int a_nScalarsPerPixel = a_oQuery.GetScalarsPerFormat( a_oImage );

// Transform into a temporary object 'xform'.
auto Uint8Array xform = new Uint8Array( a_oImage.SizeInBytes(), 0 );
auto Uint8ArrayView xform_view = xform.GetView();

// Note that we must multiply with width
// of the Image by the number of scalars
// for each pixel in the Image.
auto Int32Array a_aeTransformOptions;
a_aeTransformOptions.Add( Enum.ImageRotateOptions_NoRotation() );
a_aeTransformOptions.Add( Enum.ImageFlipOptions_FlipHeight() );
a_aeTransformOptions.Add( a_oImage.Width * a_nScalarsPerPixel );
a_aeTransformOptions.Add( a_oImage.Height );
a_aeTransformOptions.Add( 0 );

// Execute the transformation.
bool a_bXform = a_auAlgorithms.TransformOrientation(
   src_view.First, src_view.Last, xform_view.First, a_aeTransformOptions );

// Copy the transformed results back onto the Image.
bool a_bCopy = a_auAlgorithms.Copy(
   xform_view.First, xform_view.Last, src_view.First );

// Save the Image to disk. You must specify
// a valid path. The path shown below is
// for example purposes only.
a_oImage.SaveFile( "D:\\MyFolder\\out.png" );