Beispiel #1
0
        private void doRotationMethodGUI(ref RotationMethod rotationMethod)
        {
            GUILayout.BeginHorizontal();

              GUI.color = rotationMethod == RotationMethod.None ? Color.green : Color.white;
              if (GUILayout.Button("No Rotation")) {
            rotationMethod = RotationMethod.None;
              }

              GUI.color = rotationMethod == RotationMethod.Single ? Color.green : Color.white;
              if (GUILayout.Button("Single Axis")) {
            rotationMethod = RotationMethod.Single;
              }

              GUI.color = rotationMethod == RotationMethod.Full ? Color.green : Color.white;
              if (GUILayout.Button("Full Rotation")) {
            rotationMethod = RotationMethod.Full;
              }

              GUI.color = Color.white;

              GUILayout.EndHorizontal();
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new image by rotating this image about it's centre.
        /// </summary>
        /// <remarks>
        /// Please note the following:
        /// <list type="bullet">
        /// <item>
        /// Rotation will bring in either white or black pixels, as specified by <paramref name="fillColor" /> from
        /// the outside as required.
        /// </item>
        /// <item>Above 20 degrees, sampling rotation will be used if shear was requested.</item>
        /// <item>Colormaps are removed for rotation by area map and shear.</item>
        /// <item>
        /// The resulting image can be expanded so that no image pixels are lost. To invoke expansion,
        /// input the original width and height. For repeated rotation, use of the original width and heigh allows
        /// expansion to stop at the maximum required size which is a square of side = sqrt(w*w + h*h).
        /// </item>
        /// </list>
        /// <para>
        /// Please note there is an implicit assumption about RGB component ordering.
        /// </para>
        /// </remarks>
        /// <param name="angle">The angle to rotate by, in radians; clockwise is positive.</param>
        /// <param name="method">The rotation method to use.</param>
        /// <param name="fillColor">The fill color to use for pixels that are brought in from the outside.</param>
        /// <param name="width">The original width; use 0 to avoid embedding</param>
        /// <param name="height">The original height; use 0 to avoid embedding</param>
        /// <returns>The image rotated around it's centre.</returns>
        public Pix Rotate(float angle, RotationMethod method = RotationMethod.AreaMap, RotationFill fillColor = RotationFill.White, int? width = null, int? height = null)
        {
            if(width == null) width = this.Width;
            if(height == null) height = this.Height;

            if(Math.Abs(angle) < VerySmallAngle) return this.Clone();

            IntPtr resultHandle;

            var rotations = 2 * angle / Math.PI;
            if(Math.Abs(rotations - Math.Floor(rotations)) < VerySmallAngle) {
                // handle special case of orthoganal rotations (90, 180, 270)
                resultHandle = Interop.LeptonicaApi.Native.pixRotateOrth(handle, (int)rotations);
            } else {
                // handle general case
                resultHandle = Interop.LeptonicaApi.Native.pixRotate(handle, angle, method, fillColor, width.Value, height.Value);
            }

            if(resultHandle == IntPtr.Zero) throw new LeptonicaException("Failed to rotate image around it's centre.");

            return new Pix(resultHandle);
        }
    // Update is called once per frame
    void Update()
    {
        if (this.targetMetadataParser.ProjectName == null || this.targetMetadataParser.ProjectName == "") {
            this.targetMetadataParser.ProjectName = this.projectName;
            this.targetMetadataParser.csvMetadataFile = this.csvMetadataFile;
        }

        if (this.targetMetadataParser.output != null && !this.createdQuads) {
            this.rootDir = this.projectName;
            if (!(rootDir.EndsWith("/") || rootDir.EndsWith("//"))) {
                rootDir += "/";
            }
            this.createQuads();
            this.createdQuads = true;
        }

        if (this.visualizationScale != this._visualizationScale && this.canUpdateLive) {
            this._visualizationScale = this.visualizationScale;
            this.calculateQuadPositions();
        }

        if (this.rotateAll != this._rotateAll && this.canUpdateLive) {
            this._rotateAll = this.rotateAll;
            this.calculateQuadPositions();
        }

        if (this.quadScale != this._quadScale && this.canUpdateLive) {
            this._quadScale = this.quadScale;
            this.rescaleQuads();
        }

        if (this.rotationMethod != this._rotationMethod && this.canUpdateLive) {
            this._rotationMethod = this.rotationMethod;
            this.calculateQuadPositions();
        }

        if ((!writtenHeights) && Input.GetKey ("h"))
        {
            writtenHeights = true;
            Debug.Log ("print heights");
            System.IO.StreamWriter file = new System.IO.StreamWriter("d:\\heights_" + csvMetadataFile.name + ".csv");
            foreach (MetaDataItem mdi in this.targetMetadataParser.output) {

                file.WriteLine(mdi.transform.position.y + "," + mdi.filename);
            }
            file.Close();
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (this.targetMetadataParser.ProjectName == null || this.targetMetadataParser.ProjectName == "") {
            this.targetMetadataParser.ProjectName = this.projectName;
            this.targetMetadataParser.csvMetadataFile = this.csvMetadataFile;
        }

        if (this.targetMetadataParser.output != null && !this.createdQuads) {
            this.rootDir = this.projectName;
            if (!(rootDir.EndsWith("/") || rootDir.EndsWith("//"))) {
                rootDir += "/";
            }
            this.createQuads();
            this.createdQuads = true;
        }

        if (this.visualizationScale != this._visualizationScale && this.canUpdateLive) {
            this._visualizationScale = this.visualizationScale;
            this.calculateQuadPositions();
        }

        if (this.rotateAll != this._rotateAll && this.canUpdateLive) {
            this._rotateAll = this.rotateAll;
            this.calculateQuadPositions();
        }

        if (this.quadScale != this._quadScale && this.canUpdateLive) {
            this._quadScale = this.quadScale;
            this.rescaleQuads();
        }

        if (this.rotationMethod != this._rotationMethod && this.canUpdateLive) {
            this._rotationMethod = this.rotationMethod;
            this.calculateQuadPositions();
        }
    }
 public static extern IntPtr pixRotate(HandleRef pixs, float angle, RotationMethod type, RotationFill fillColor, int width, int heigh);
Beispiel #6
0
        /// <summary>
        /// Creates a new image by rotating this image about it's centre.
        /// </summary>
        /// <remarks>
        /// Please note the following:
        /// <list type="bullet">
        /// <item>
        /// Rotation will bring in either white or black pixels, as specified by <see cref="fillColor" /> from
        /// the outside as required.
        /// </item>
        /// <item>Above 20 degrees, sampling rotation will be used if shear was requested.</item>
        /// <item>Colormaps are removed for rotation by area map and shear.</item>
        /// <item>
        /// The resulting image can be expanded so that no image pixels are lost. To invoke expansion,
        /// input the original width and height. For repeated rotation, use of the original width and heigh allows
        /// expansion to stop at the maximum required size which is a square of side = sqrt(w*w + h*h).
        /// </item>
        /// </list>
        /// <para>
        /// Please note there is an implicit assumption about RGB component ordering.
        /// </para>
        /// </remarks>
        /// <param name="angle">The angle to rotate by, in radians; clockwise is positive.</param>
        /// <param name="method">The rotation method to use.</param>
        /// <param name="fillColor">The fill color to use for pixels that are brought in from the outside.</param>
        /// <param name="width">The original width; use 0 to avoid embedding</param>
        /// <param name="height">The original height; use 0 to avoid embedding</param>
        /// <returns>The image rotated around it's centre.</returns>
        public Pix Rotate(float angle, RotationMethod method = RotationMethod.AreaMap, RotationFill fillColor = RotationFill.White, int? width = null, int? height = null)
        {
            if(width == null) width = this.Width;
            if(height == null) height = this.Height;
            var handle = Interop.LeptonicaApi.pixRotate(Handle, angle, method, fillColor, width.Value, height.Value);
            if(handle == IntPtr.Zero) throw new LeptonicaException("Failed to rotate image around it's centre.");

            return new Pix(handle);
        }