Beispiel #1
0
        /// <summary>
        ///		performs the actual enc/dec.
        /// </summary>
        /// <param name="inputBytes">input byte array</param>
        /// <param name="Encrpyt">wheather or not to perform enc/dec</param>
        /// <returns>byte array output</returns>
        private byte[] Transform(byte[] inputBytes, TransformDirection direction)
        {
            //get the correct transform
            ICryptoTransform transform = GetEncryptionTransform(direction);

            //memory stream for output
            MemoryStream memStream = new MemoryStream();

            try
            {
                //setup the cryption - output written to memstream
                CryptoStream cryptStream = new CryptoStream(memStream, transform, CryptoStreamMode.Write);

                //write data to cryption engine
                cryptStream.Write(inputBytes, 0, inputBytes.Length);

                //we are finished
                cryptStream.FlushFinalBlock();

                //get result
                byte[] output = memStream.ToArray();

                //finished with engine, so close the stream
                cryptStream.Close();

                return(output);
            }
            catch (Exception e)
            {
                //throw an error
                throw new Exception("Error in symmetric engine. Error : " + e.Message, e);
            }
        }
Beispiel #2
0
        private void beatmapChanged(WorkingBeatmap beatmap)
        {
            TransformDirection direction = TransformDirection.None;

            if (current != null)
            {
                bool audioEquals = beatmap?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false;

                if (audioEquals)
                {
                    direction = TransformDirection.None;
                }
                else if (queuedDirection.HasValue)
                {
                    direction       = queuedDirection.Value;
                    queuedDirection = null;
                }
                else
                {
                    //figure out the best direction based on order in playlist.
                    var last = beatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo?.ID).Count();
                    var next = beatmap == null ? -1 : beatmapSets.TakeWhile(b => b.ID != beatmap.BeatmapSetInfo?.ID).Count();

                    direction = last > next ? TransformDirection.Prev : TransformDirection.Next;
                }
            }

            current = beatmap;

            progressBar.CurrentTime = 0;

            updateDisplay(current, direction);

            queuedDirection = null;
        }
Beispiel #3
0
 public object Transform(object value, TransformDirection direction)
 {
     Tracer.TraceInformation("enter-transform {0}", direction);
     try
     {
         if (this.Transforms != null)
         {
             foreach (Transform t in Transforms.Transform)
             {
                 Tracer.TraceInformation("input[{0}]: '{1}'", t.GetType().Name, value);
                 value = t.Convert(value);
                 Tracer.TraceInformation("output[{0}]: '{1}'", t.GetType().Name, value);
             }
         }
         else
         {
             Tracer.TraceInformation("no-transforms");
         }
         Tracer.TraceInformation("return-value: '{0}'", value);
     }
     catch (Exception ex)
     {
         Tracer.TraceError("transform {0}", ex.GetBaseException());
         throw;
     }
     finally
     {
         Tracer.TraceInformation("exit-transform {0}", direction);
     }
     return(value);
 }
Beispiel #4
0
        private Rectangle Transform(Rectangle rectangle, TransformDirection direction)
        {
            var upperLeft   = this.TransformPoint(rectangle.Left, rectangle.Top, direction);
            var bottomRight = this.TransformPoint(rectangle.Right, rectangle.Bottom, direction);

            return(Rectangle.FromLTRB(upperLeft.X, upperLeft.Y, bottomRight.X, bottomRight.Y));
        }
        /// <summary>
        /// Makes the FFT full.
        /// </summary>
        /// <param name="functionVector">The function vector.</param>
        /// <param name="direction">The direction.</param>
        /// <returns></returns>
        public static Complex[] MakeFFT(Complex[] functionVector, TransformDirection direction)
        {
            Complexibility = 0;
            var values = MakeFFTRecursive(functionVector, direction);

            FFTReorder(values);
            return(values);
        }
Beispiel #6
0
		public static Vector3 GetDirectionVector(Transform transform, TransformDirection dir) {
			switch(dir) {
			case TransformDirection.Up:
				return transform.up;
			case TransformDirection.Right:
				return transform.right;
			case TransformDirection.Forward:
			default:
				return transform.forward;
			}
		}
Beispiel #7
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            //we might be off-screen when this update comes in.
            //rather than Scheduling, manually handle this to avoid possible memory contention.
            pendingBeatmapSwitch?.Cancel();

            pendingBeatmapSwitch = Schedule(delegate
            {
                // todo: this can likely be replaced with WorkingBeatmap.GetBeatmapAsync()
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists
                    {
                        title.Current = null;
                        title.Text    = @"Nothing to play";

                        artist.Current = null;
                        artist.Text    = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Metadata;
                        title.Current            = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title);
                        artist.Current           = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist);
                    }
                });

                LoadComponentAsync(new Background(beatmap)
                {
                    Depth = float.MaxValue
                }, newBackground =>
                {
                    switch (direction)
                    {
                    case TransformDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(-400, 500, Easing.OutCubic);
                        break;

                    case TransformDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(400, 500, Easing.OutCubic);
                        break;
                    }

                    background.Expire();
                    background = newBackground;

                    playerContainer.Add(newBackground);
                });
            });
        }
Beispiel #8
0
        public MapleCipher(short majorVersion, byte[] IV, TransformDirection transformDirection)
        {
            m_majorVersion = majorVersion;

            m_IV = new byte[IvLength];
            Buffer.BlockCopy(IV, 0, m_IV, 0, IvLength);

            m_transformer =
                transformDirection == TransformDirection.Encrypt ?
                new Action <byte[]>(Encrypt) : new Action <byte[]>(Decrypt);
        }
        bool PickOrthogonal(Vector3 mouse)
        {
            var cam = Camera.main;

            var matrix = GetTranform();

            var origin      = cam.WorldToScreenPoint(matrix.MultiplyPoint(Vector3.zero)).xy();
            var right       = cam.WorldToScreenPoint(matrix.MultiplyPoint(Vector3.right)).xy() - origin;
            var rightHead   = cam.WorldToScreenPoint(matrix.MultiplyPoint(Vector3.right * (1f + HANDLER_SIZE))).xy() - origin;
            var up          = cam.WorldToScreenPoint(matrix.MultiplyPoint(Vector3.up)).xy() - origin;
            var upHead      = cam.WorldToScreenPoint(matrix.MultiplyPoint(Vector3.up * (1f + HANDLER_SIZE))).xy() - origin;
            var forward     = cam.WorldToScreenPoint(matrix.MultiplyPoint(Vector3.forward)).xy() - origin;
            var forwardHead = cam.WorldToScreenPoint(matrix.MultiplyPoint(Vector3.forward * (1f + HANDLER_SIZE))).xy() - origin;
            var v           = mouse.xy() - origin;
            var vl          = v.magnitude;

            // Add THRESHOLD to each magnitude to ignore a direction.

            var xl = v.Orth(right).magnitude;

            if (Vector2.Dot(v, right) <= -float.Epsilon || vl > rightHead.magnitude)
            {
                xl += THRESHOLD;
            }

            var yl = v.Orth(up).magnitude;

            if (Vector2.Dot(v, up) <= -float.Epsilon || vl > upHead.magnitude)
            {
                yl += THRESHOLD;
            }

            var zl = v.Orth(forward).magnitude;

            if (Vector2.Dot(v, forward) <= -float.Epsilon || vl > forwardHead.magnitude)
            {
                zl += THRESHOLD;
            }

            if (xl < yl && xl < zl && xl < THRESHOLD)
            {
                selected = TransformDirection.X;
            }
            else if (yl < xl && yl < zl && yl < THRESHOLD)
            {
                selected = TransformDirection.Y;
            }
            else if (zl < xl && zl < yl && zl < THRESHOLD)
            {
                selected = TransformDirection.Z;
            }

            return(selected != TransformDirection.None);
        }
Beispiel #10
0
        public MapleCryptograph(short majorVersion, byte[] IV, TransformDirection transformDirection)
        {
            m_majorVersion = majorVersion;

            m_IV = new byte[4];
            Buffer.BlockCopy(IV, 0, m_IV, 0, 4);

            m_direction = transformDirection;

            //Like i just cant deal with a cmp every time idk
            m_transformer = m_direction == TransformDirection.Encrypt ? new Action <byte[]>(EncryptTransform) : new Action <byte[]>(DecryptTransform);
        }
Beispiel #11
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            //we might be off-screen when this update comes in.
            //rather than Scheduling, manually handle this to avoid possible memory contention.
            pendingBeatmapSwitch = () =>
            {
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists
                    {
                        title.Current = null;
                        title.Text    = @"Nothing to play";

                        artist.Current = null;
                        artist.Text    = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
                        title.Current            = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title);
                        artist.Current           = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist);
                    }
                });

                dragContainer.Add(new AsyncLoadWrapper(new MusicControllerBackground(beatmap)
                {
                    OnLoadComplete = d =>
                    {
                        switch (direction)
                        {
                        case TransformDirection.Next:
                            d.Position = new Vector2(400, 0);
                            d.MoveToX(0, 500, EasingTypes.OutCubic);
                            currentBackground.MoveToX(-400, 500, EasingTypes.OutCubic);
                            break;

                        case TransformDirection.Prev:
                            d.Position = new Vector2(-400, 0);
                            d.MoveToX(0, 500, EasingTypes.OutCubic);
                            currentBackground.MoveToX(400, 500, EasingTypes.OutCubic);
                            break;
                        }
                        currentBackground.Expire();
                        currentBackground = d;
                    }
                })
                {
                    Depth = float.MaxValue,
                });
            };
        }
Beispiel #12
0
        private Vector3 Transform(TransformDirection direction, Vector3 pos)
        {
            switch (direction)
            {
            case TransformDirection.LocalToServer:
                return(TransformToServerCoordinates(pos));

            case TransformDirection.ServerToLocal:
                return(TransformToLocalCoordinates(pos));

            default:
                throw new InvalidTransformDirectionException(direction);
            }
        }
Beispiel #13
0
        private Quaternion Transform(TransformDirection direction, Quaternion rot)
        {
            switch (direction)
            {
            case TransformDirection.LocalToServer:
                return(TransformToServerCoordinates(rot));

            case TransformDirection.ServerToLocal:
                return(TransformToLocalCoordinates(rot));

            default:
                throw new InvalidTransformDirectionException(direction);
            }
        }
Beispiel #14
0
        private RigidbodyState Transform(TransformDirection direction, ref RigidbodyState fromRbs, bool transformVelocity)
        {
            var toRbs = new RigidbodyState {
                position = Transform(direction, fromRbs.position),
                rotation = Transform(direction, fromRbs.rotation)
            };

            if (transformVelocity)
            {
                toRbs.velocity        = TransformVector(direction, fromRbs.velocity);
                toRbs.angularVelocity = TransformVector(direction, fromRbs.angularVelocity);
            }
            return(toRbs);
        }
Beispiel #15
0
            public unsafe int Transform(double *points, int pointCount, TransformDirection direction = TransformDirection.Forward)
            {
                switch (direction)
                {
                case TransformDirection.Forward:
                    return(Proj6Native.proj_trans_generic(pjNative, Proj6Native.PJ_DIRECTION.PJ_FWD, points, pointCount));

                case TransformDirection.Inverse:
                    return(Proj6Native.proj_trans_generic(pjNative, Proj6Native.PJ_DIRECTION.PJ_INV, points, pointCount));

                default:
                    return(Proj6Native.proj_trans_generic(pjNative, Proj6Native.PJ_DIRECTION.PJ_IDENT, points, pointCount));
                }
            }
        /// <summary>
        /// Makes the FFT.
        /// </summary>
        /// <param name="functionVector">The function vector.</param>
        /// <param name="direction">The direction.</param>
        /// <returns></returns>
        private static Complex[] MakeFFTRecursive(Complex[] functionVector, TransformDirection direction)
        {
            if (functionVector.Length == 1)
            {
                return(functionVector);
            }


            // ReSharper disable once LocalVariableHidesMember
            var N = functionVector.Length;

            var wN = Complex.Exp(-(int)direction * 2 * Math.PI * Complex.ImaginaryOne / N);
            var w  = new Complex(1, 0);
            // ReSharper disable once InconsistentNaming
            var FFTVector = new Complex[N];

            var leftPath  = new Complex[N / 2];
            var rightPath = new Complex[N / 2];

            for (var i = 0; i < N / 2; i++)
            {
                leftPath[i]  = functionVector[i] + functionVector[i + N / 2];
                rightPath[i] = (functionVector[i] - functionVector[i + N / 2]) * w;
                w           *= wN;
                Complexibility++;
            }

            var leftResult  = MakeFFTRecursive(leftPath, direction);
            var rightResult = MakeFFTRecursive(rightPath, direction);

            if (direction == TransformDirection.Direct)
            {
                for (var i = 0; i < N / 2; i++)
                {
                    FFTVector[i]         = leftResult[i] / 2;
                    FFTVector[i + N / 2] = rightResult[i] / 2;
                }
            }
            else
            {
                for (var i = 0; i < N / 2; i++)
                {
                    FFTVector[i]         = leftResult[i];
                    FFTVector[i + N / 2] = rightResult[i];
                }
            }

            return(FFTVector);
        }
Beispiel #17
0
 /// <summary>
 ///		returns the symmetric engine and creates the encyptor/decryptor
 /// </summary>
 /// <param name="encrypt">whether to return a encrpytor or decryptor</param>
 /// <returns>ICryptoTransform</returns>
 private ICryptoTransform GetEncryptionTransform(TransformDirection direction)
 {
     if (m_bCalculateNewKeyAndIV)
     {
         CalculateNewKeyAndIV();
     }
     if (direction == TransformDirection.Encrypt)
     {
         return(GetEncryptionAlgorithm().CreateEncryptor(m_Key, m_IV));
     }
     else
     {
         return(GetEncryptionAlgorithm().CreateDecryptor(m_Key, m_IV));
     }
 }
Beispiel #18
0
        private Point TransformPoint(int xPosition, int yPosition, TransformDirection direction)
        {
            var scaleFactor = this.ScaleFactor;

            if (scaleFactor >= 1.0f)
            {
                return(new Point(xPosition, yPosition));
            }

            scaleFactor = direction == TransformDirection.ToDevice ? 1.0f / scaleFactor : scaleFactor;

            var transformedPoint = new Point((int)(xPosition * scaleFactor), (int)(yPosition * scaleFactor));

            return(transformedPoint);
        }
Beispiel #19
0
        private Vector3 TransformVector(TransformDirection direction, Vector3 vector)
        {
            GenerateMatrices();
            switch (direction)
            {
            case TransformDirection.LocalToServer:
                return(worldToLocalMatrix.MultiplyVector(vector));

            case TransformDirection.ServerToLocal:
                return(localToWorldMatrix.MultiplyVector(vector));

            default:
                throw new InvalidTransformDirectionException(direction);
            }
        }
Beispiel #20
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            // avoid using scheduler as our scheduler may not be run for a long time, holding references to beatmaps.
            pendingBeatmapSwitch = delegate
            {
                // todo: this can likely be replaced with WorkingBeatmap.GetBeatmapAsync()
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists
                    {
                        title.Text  = @"Nothing to play";
                        artist.Text = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Metadata;
                        title.Text  = new LocalisedString((metadata.TitleUnicode, metadata.Title));
                        artist.Text = new LocalisedString((metadata.ArtistUnicode, metadata.Artist));
                    }
                });

                LoadComponentAsync(new Background(beatmap)
                {
                    Depth = float.MaxValue
                }, newBackground =>
                {
                    switch (direction)
                    {
                    case TransformDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(-400, 500, Easing.OutCubic);
                        break;

                    case TransformDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(400, 500, Easing.OutCubic);
                        break;
                    }

                    background.Expire();
                    background = newBackground;

                    playerContainer.Add(newBackground);
                });
            };
        }
Beispiel #21
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            //we might be off-screen when this update comes in.
            //rather than Scheduling, manually handle this to avoid possible memory contention.
            pendingBeatmapSwitch = () =>
            {
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null)
                    {
                        title.Text  = @"Nothing to play";
                        artist.Text = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
                        title.Text  = unicodeString(metadata.Title, metadata.TitleUnicode);
                        artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
                    }
                });

                dragContainer.Add(new AsyncLoadContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Depth            = float.MaxValue,
                    Children         = new[] { new MusicControllerBackground(beatmap) },
                    FinishedLoading  = d =>
                    {
                        switch (direction)
                        {
                        case TransformDirection.Next:
                            d.Position = new Vector2(400, 0);
                            d.MoveToX(0, 500, EasingTypes.OutCubic);
                            currentBackground.MoveToX(-400, 500, EasingTypes.OutCubic);
                            break;

                        case TransformDirection.Prev:
                            d.Position = new Vector2(-400, 0);
                            d.MoveToX(0, 500, EasingTypes.OutCubic);
                            currentBackground.MoveToX(400, 500, EasingTypes.OutCubic);
                            break;
                        }
                        currentBackground.Expire();
                        currentBackground = d;
                    }
                });
            };
        }
        public bool Pick(Vector3 mouse)
        {
            selected = TransformDirection.None;

            switch (mode)
            {
            case TransformMode.Translate:
            case TransformMode.Scale:
                return(PickOrthogonal(mouse));

            case TransformMode.Rotate:
                return(PickSphere(mouse));
            }

            return(false);
        }
Beispiel #23
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            //we might be off-screen when this update comes in.
            //rather than Scheduling, manually handle this to avoid possible memory contention.
            pendingBeatmapSwitch = () =>
            {
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null)
                    {
                        title.Text  = @"Nothing to play";
                        artist.Text = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
                        title.Text  = unicodeString(metadata.Title, metadata.TitleUnicode);
                        artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
                    }
                });

                MusicControllerBackground newBackground;

                (newBackground = new MusicControllerBackground(beatmap)).LoadAsync(game, delegate
                {
                    dragContainer.Add(newBackground);

                    switch (direction)
                    {
                    case TransformDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                        backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic);
                        break;

                    case TransformDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                        backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic);
                        break;
                    }

                    backgroundSprite.Expire();
                    backgroundSprite = newBackground;
                });
            };
        }
Beispiel #24
0
        public cuDoubleComplex[] PerformFFT(cuDoubleComplex[] data, int n, TransformDirection direction)
        {
            f_plan = new CudaFFTPlan2D(n, n, cufftType.Z2Z);

            CudaDeviceVariable <cuDoubleComplex> d_signal = new CudaDeviceVariable <cuDoubleComplex>(n * n);
            CudaDeviceVariable <cuDoubleComplex> o_signal = new CudaDeviceVariable <cuDoubleComplex>(n * n);

            d_signal.CopyToDevice(data);
            f_plan.Exec(d_signal.DevicePointer, o_signal.DevicePointer, direction);


            cuDoubleComplex[] result = new cuDoubleComplex[n * n];

            o_signal.CopyToHost(result);
            d_signal.Dispose();
            return(result);
        }
        /// <summary>
        /// Conversion of Euler angles to quaternion
        /// </summary>
        void EulerAnglesToRotation()
        {
            if (this.ProcessDirection != TransformDirection.None)
            {
                return;
            }

            this.ProcessDirection = TransformDirection.EulerToQuaternion;

            this.Rotation = TransformationHelper.UnitQuaternionFromEulerAngles(Psi, Theta, Phi);
            var mat = new Matrix3D();

            mat.Rotate(this.Rotation);
            this.AirPlaneMatrixTransform = mat;

            this.ProcessDirection = TransformDirection.None;
        }
Beispiel #26
0
        private void updateDisplay(BeatmapMeta beatmap, TransformDirection direction)
        {
            pendingBeatmapSwitch?.Cancel();

            pendingBeatmapSwitch = Schedule(delegate
            {
                if (beatmap == null)
                {
                    title.Text  = @"Nothing to play!";
                    artist.Text = @"Nothing to play!";
                }
                else
                {
                    SongMetadata metadata = beatmap.Metadata.Song;
                    title.Text            = new LocalisedString((metadata.NameUnicode, metadata.Name));
                    artist.Text           = new LocalisedString((metadata.AuthorUnicode, metadata.Author));
                }

                LoadComponentAsync(new Background(beatmap)
                {
                    Depth = float.MaxValue
                }, newBackground =>
                {
                    switch (direction)
                    {
                    case TransformDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(-400, 500, Easing.OutCubic);
                        break;

                    case TransformDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(400, 500, Easing.OutCubic);
                        break;
                    }

                    background.Expire();
                    background = newBackground;

                    playerContainer.Add(newBackground);
                });
            });
        /// <summary>
        /// Creates a new managed transform instance, reading necessary
        /// setting values from the provided <see cref="ISymmetricAlgorithm" />
        /// instance.
        /// </summary>
        /// <param name="algorithm">
        /// A <see cref="ISymmetricAlgorithm" /> instance from which to take
        /// setting values.
        /// </param>
        /// <param name="rgbIv">
        /// The initialization vector to use.
        /// </param>
        /// <param name="transformDirection">
        /// The direction of the transform (encryption or decryption).
        /// </param>
        /// <param name="endianness">
        /// The endianness convention for the algorithm.
        /// </param>
        protected ManagedTransformBase(ISymmetricAlgorithm algorithm, byte[] rgbIv, TransformDirection transformDirection, Endianness endianness)
        {
            Endianness    = endianness;
            _bytesToWords = endianness == Endianness.Little
                                ? (BytesToWords)Utils.BytesToWordsLittleEndian
                                : Utils.BytesToWordsBigEndian;
            _writeWordsIntoBytes = endianness == Endianness.Little
                                ? (WriteWordsIntoBytes)Utils.WriteWordsIntoBytesLittleEndian
                                : Utils.WriteWordsIntoBytesBigEndian;
            PaddingMode          = algorithm.Padding;
            BlockSizeBytes       = algorithm.BlockSize >> 3;
            Mode                 = algorithm.ExtendedMode;
            NonceCombinationMode = algorithm.NonceCombinationMode;
            _registerShiftSize   = algorithm.RegisterShiftSize;
            _feedbackValue       = new byte[BlockSizeBytes];
            _iv = new byte[BlockSizeBytes];
            if (rgbIv != null)
            {
                rgbIv.CopyTo(_feedbackValue, 0);
                rgbIv.CopyTo(_iv, 0);
                if (Mode == ExtendedCipherMode.CTR)
                {
                    switch (NonceCombinationMode)
                    {
                    case NonceCombinationMode.Concatenate:
                        _counterSize = BlockSizeBytes - rgbIv.Length;
                        _counter     = new byte[_counterSize];
                        break;

                    case NonceCombinationMode.Xor:
                        _counterSize = BlockSizeBytes;
                        _counter     = new byte[_counterSize];
                        break;

                    case NonceCombinationMode.Add:
                        _counterSize = BlockSizeBytes;
                        _counter     = (byte[])_feedbackValue.Clone();
                        break;
                    }
                    _initial = true;
                }
            }
            _transformDirection = transformDirection;
        }
Beispiel #28
0
 private void TransformObj <T>(TransformDirection direction, T obj, string key, bool serverManaged = false, bool isStatic = false)
 {
     foreach (PropertyInfo prop in GetEncryptedProperties(obj, serverManaged))
     {
         // Weird things would happen here if prop.PropertyType is not a
         // string. We should probably enforce that.
         var    before = prop.GetValue(obj) as string;
         string after;
         if (direction == TransformDirection.ToCipher)
         {
             after = Encrypt(before, key, isStatic);
         }
         else
         {
             after = Decrypt(before, key, isStatic);
         }
         prop.SetValue(obj, after);
     }
 }
        /// <summary>
        /// Gets the fast walsh transform.
        /// </summary>
        /// <param name="functionVector">The function vector.</param>
        /// <param name="direction">The direction.</param>
        /// <returns>Result of Walsh transform</returns>
        /// <exception cref="System.ArgumentException">Invalid length of vector.</exception>
        public static double[] GetFastWalshTransform(double[] functionVector, TransformDirection direction)
        {
            if (functionVector.Length == 1)
            {
                return functionVector;
            }

            // ReSharper disable once InconsistentNaming
            var N = functionVector.Length;

            var leftPath = new double[N / 2];
            var rightPath = new double[N / 2];

            for (var i = 0; i < N / 2; i++)
            {
                leftPath[i] = functionVector[i] + functionVector[i + N / 2];
                rightPath[i] = functionVector[i] - functionVector[i + N / 2];
            }

            var leftResult = GetFastWalshTransform(leftPath, direction);
            var rightResult = GetFastWalshTransform(rightPath, direction);

            var result = new double[N];

            if (direction == TransformDirection.Direct)
            {
                for (var i = 0; i < N / 2; i++)
                {
                    result[i] = leftResult[i] / 2;
                    result[i + N / 2] = rightResult[i] / 2;
                }
            }
            else
            {
                for (var i = 0; i < N / 2; i++)
                {
                    result[i] = leftResult[i];
                    result[i + N / 2] = rightResult[i];
                }
            }

            return result;
        }
Beispiel #30
0
        /// <summary>
        /// Gets the fast walsh transform.
        /// </summary>
        /// <param name="functionVector">The function vector.</param>
        /// <param name="direction">The direction.</param>
        /// <returns>Result of Walsh transform</returns>
        /// <exception cref="System.ArgumentException">Invalid length of vector.</exception>
        public static double[] GetFastWalshTransform(double[] functionVector, TransformDirection direction)
        {
            if (functionVector.Length == 1)
            {
                return(functionVector);
            }

            // ReSharper disable once InconsistentNaming
            var N = functionVector.Length;

            var leftPath  = new double[N / 2];
            var rightPath = new double[N / 2];

            for (var i = 0; i < N / 2; i++)
            {
                leftPath[i]  = functionVector[i] + functionVector[i + N / 2];
                rightPath[i] = functionVector[i] - functionVector[i + N / 2];
            }

            var leftResult  = GetFastWalshTransform(leftPath, direction);
            var rightResult = GetFastWalshTransform(rightPath, direction);

            var result = new double[N];

            if (direction == TransformDirection.Direct)
            {
                for (var i = 0; i < N / 2; i++)
                {
                    result[i]         = leftResult[i] / 2;
                    result[i + N / 2] = rightResult[i] / 2;
                }
            }
            else
            {
                for (var i = 0; i < N / 2; i++)
                {
                    result[i]         = leftResult[i];
                    result[i + N / 2] = rightResult[i];
                }
            }

            return(result);
        }
Beispiel #31
0
        private void beatmapChanged(ValueChangedEvent <WorkingBeatmap> beatmap)
        {
            TransformDirection direction = TransformDirection.None;

            if (current != null)
            {
                bool audioEquals = beatmap.NewValue?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false;

                if (audioEquals)
                {
                    direction = TransformDirection.None;
                }
                else if (queuedDirection.HasValue)
                {
                    direction       = queuedDirection.Value;
                    queuedDirection = null;
                }
                else
                {
                    //figure out the best direction based on order in playlist.
                    var last = beatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo?.ID).Count();
                    var next = beatmap.NewValue == null ? -1 : beatmapSets.TakeWhile(b => b.ID != beatmap.NewValue.BeatmapSetInfo?.ID).Count();

                    direction = last > next ? TransformDirection.Prev : TransformDirection.Next;
                }

                //current.Track.Completed -= currentTrackCompleted;
            }

            current = beatmap.NewValue;

            if (current != null)
            {
                current.Track.Completed += currentTrackCompleted;
            }

            progressBar.CurrentTime = 0;

            updateDisplay(current, direction);
            updateAudioAdjustments();

            queuedDirection = null;
        }
        /// <summary>
        /// Makes the DFT.
        /// </summary>
        /// <param name="functionVector">The function vector.</param>
        /// <param name="direction">The direction.</param>
        /// <returns>Vector of function after DFT</returns>
        public static Complex[] MakeDFT(Complex[] functionVector, TransformDirection direction)
        {
            Complexibility = 0;
            // ReSharper disable once InconsistentNaming
            var DFTVector = new Complex[N];

            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < N; j++)
                {
                    DFTVector[i] += functionVector[j] * GetComplexExponent(direction, i, j);
                    Complexibility++;
                }

                if (direction == TransformDirection.Direct)
                {
                    DFTVector[i] /= N;
                }
            }

            return DFTVector;
        }
Beispiel #33
0
 static extern Int32 gimp_drawable_transform_matrix(Int32 drawable_ID,
     double coeff_0_0,
     double coeff_0_1,
     double coeff_0_2,
     double coeff_1_0,
     double coeff_1_1,
     double coeff_1_2,
     double coeff_2_0,
     double coeff_2_1,
     double coeff_2_2,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample,
     int recursion_level,
     bool clip_result);
Beispiel #34
0
 public Drawable TransformShear(OrientationType shear_type,
     double magnitude,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample,
     int recursion_level,
     bool clip_result)
 {
     return new Drawable(gimp_drawable_transform_shear
       (ID, shear_type, magnitude, transform_direction,
        interpolation, supersample, recursion_level,
        clip_result));
 }
Beispiel #35
0
 static extern Int32 gimp_drawable_transform_rotate(Int32 drawable_ID,
     double angle,
     bool auto_center,
     int center_x,
     int center_y,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample,
     int recursion_level,
     bool clip_result);
Beispiel #36
0
 /// <summary>
 /// Executes a CUFTT transorm as defined by the cufftType.
 /// This method does an in‐place transform.
 /// </summary>
 /// <param name="iodata"></param>
 /// <param name="direction">Only unsed for transformations where direction is not implicitly given by type</param>
 public void Exec(CUdeviceptr iodata, TransformDirection direction)
 {
     switch (_type)
     {
         case cufftType.R2C:
             res = CudaFFTNativeMethods.cufftExecR2C(_handle, iodata, iodata);
             Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cufftExecR2C", res));
             break;
         case cufftType.C2R:
             res = CudaFFTNativeMethods.cufftExecC2R(_handle, iodata, iodata);
             Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cufftExecC2R", res));
             break;
         case cufftType.C2C:
             res = CudaFFTNativeMethods.cufftExecC2C(_handle, iodata, iodata, direction);
             Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cufftExecC2C", res));
             break;
         case cufftType.D2Z:
             res = CudaFFTNativeMethods.cufftExecD2Z(_handle, iodata, iodata);
             Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cufftExecD2Z", res));
             break;
         case cufftType.Z2D:
             res = CudaFFTNativeMethods.cufftExecZ2D(_handle, iodata, iodata);
             Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cufftExecZ2D", res));
             break;
         case cufftType.Z2Z:
             res = CudaFFTNativeMethods.cufftExecZ2Z(_handle, iodata, iodata, direction);
             Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cufftExecZ2Z", res));
             break;
         default:
             break;
     }
     if (res != cufftResult.Success)
         throw new CudaFFTException(res);
 }
 internal SerpentManagedTransform(ISymmetricAlgorithm algorithm, byte[] rgbKey, byte[] rgbIv, TransformDirection transformDirection)
     : base(algorithm, rgbIv, transformDirection, Endianness.Little)
 {
     _key = rgbKey;
     ComputeKeySchedule();
 }
 public static void Warp(ComplexDoubleImage src, ComplexDoubleImage dest, TransformDirection dir, Coord2D leftTop, Coord2D rightTop, Coord2D leftBottom, Coord2D rightBottom, int height, int width, SWIGTYPE_p_std__complexT_double_t border, PixelInterpolation pi) {
   VisionLabPINVOKE.Warp__SWIG_29(ComplexDoubleImage.getCPtr(src), ComplexDoubleImage.getCPtr(dest), (int)dir, Coord2D.getCPtr(leftTop), Coord2D.getCPtr(rightTop), Coord2D.getCPtr(leftBottom), Coord2D.getCPtr(rightBottom), height, width, SWIGTYPE_p_std__complexT_double_t.getCPtr(border), (int)pi);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
Beispiel #39
0
 public Drawable TransformScale(double x0, double y0,
     double x1, double y1,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample,
     int recursion_level,
     bool clip_result)
 {
     return new Drawable(gimp_drawable_transform_scale
       (ID, x0, y0, x1, y1, transform_direction,
        interpolation, supersample, recursion_level,
        clip_result));
 }
 /// <summary>
 /// Gets the complex exponent.
 /// </summary>
 /// <param name="direction">The direction.</param>
 /// <param name="i">The attribute.</param>
 /// <param name="j">The object.</param>
 /// <returns>
 /// Complex exponent
 /// </returns>
 private static Complex GetComplexExponent(TransformDirection direction, int i, int j)
 {
     return Complex.Exp(-(int)direction * 2 * Math.PI * Complex.ImaginaryOne * i * j / N);
 }
        /// <summary>
        /// Makes the FFT.
        /// </summary>
        /// <param name="functionVector">The function vector.</param>
        /// <param name="direction">The direction.</param>
        /// <returns></returns>
        private static Complex[] MakeFFTRecursive(Complex[] functionVector, TransformDirection direction)
        {
            if (functionVector.Length == 1)
            {
                return functionVector;
            }

            // ReSharper disable once LocalVariableHidesMember
            var N = functionVector.Length;

            var wN = Complex.Exp(-(int)direction * 2 * Math.PI * Complex.ImaginaryOne / N);
            var w = new Complex(1, 0);
            // ReSharper disable once InconsistentNaming
            var FFTVector = new Complex[N];

            var leftPath = new Complex[N / 2];
            var rightPath = new Complex[N / 2];

            for (var i = 0; i < N / 2; i++)
            {
                leftPath[i] = functionVector[i] + functionVector[i + N / 2];
                rightPath[i] = (functionVector[i] - functionVector[i + N / 2]) * w;
                w *= wN;
                Complexibility++;
            }

            var leftResult = MakeFFTRecursive(leftPath, direction);
            var rightResult = MakeFFTRecursive(rightPath, direction);

            if (direction == TransformDirection.Direct)
            {
                for (var i = 0; i < N / 2; i++)
                {
                    FFTVector[i] = leftResult[i] / 2;
                    FFTVector[i + N / 2] = rightResult[i] / 2;
                }
            }
            else
            {
                for (var i = 0; i < N / 2; i++)
                {
                    FFTVector[i] = leftResult[i];
                    FFTVector[i + N / 2] = rightResult[i];
                }
            }

            return FFTVector;
        }
Beispiel #42
0
 public Drawable Transform2d(double source_x, double source_y,
     double scale_x, double scale_y,
     double angle, double dest_x, double dest_y,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample, int recursion_level,
     bool clip_result)
 {
     return new Drawable(gimp_drawable_transform_2d
       (ID, source_x, source_y, scale_x, scale_y,
        angle, dest_x, dest_y, transform_direction,
        interpolation, supersample, recursion_level,
        clip_result));
 }
Beispiel #43
0
 static extern Int32 gimp_drawable_transform_shear(Int32 drawable_ID,
     OrientationType shear_type,
     double magnitude,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample,
     int recursion_level,
     bool clip_result);
Beispiel #44
0
 public Drawable TransformMatrix(double coeff_0_0, double coeff_0_1,
     double coeff_0_2, double coeff_1_0,
     double coeff_1_1, double coeff_1_2,
     double coeff_2_0, double coeff_2_1,
     double coeff_2_2,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample,
     int recursion_level,
     bool clip_result)
 {
     return new Drawable(gimp_drawable_transform_matrix
       (ID, coeff_0_0, coeff_0_1, coeff_0_2, coeff_1_0,
        coeff_1_1, coeff_1_2, coeff_2_0, coeff_2_1,
        coeff_2_2, transform_direction, interpolation,
        supersample, recursion_level, clip_result));
 }
Beispiel #45
0
 public Drawable TransformRotate(double angle,
     bool auto_center,
     int center_x, int center_y,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample,
     int recursion_level,
     bool clip_result)
 {
     return new Drawable(gimp_drawable_transform_rotate
       (ID, angle, auto_center, center_x, center_y,
        transform_direction, interpolation, supersample,
        recursion_level, clip_result));
 }
Beispiel #46
0
 static extern bool gimp_context_set_transform_direction(TransformDirection transform_direction);
 public static void Warp(HSV888Image src, HSV888Image dest, TransformDirection dir, Coord2D leftTop, Coord2D rightTop, Coord2D leftBottom, Coord2D rightBottom, int height, int width, HSV888Pixel border) {
   VisionLabPINVOKE.Warp__SWIG_18(HSV888Image.getCPtr(src), HSV888Image.getCPtr(dest), (int)dir, Coord2D.getCPtr(leftTop), Coord2D.getCPtr(rightTop), Coord2D.getCPtr(leftBottom), Coord2D.getCPtr(rightBottom), height, width, HSV888Pixel.getCPtr(border));
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public static void DiscreteFourierT(ComplexFloatImage image, TransformDirection dir) {
   VisionLabPINVOKE.DiscreteFourierT__SWIG_1(ComplexFloatImage.getCPtr(image), (int)dir);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public static void Warp(YUV161616Image src, YUV161616Image dest, TransformDirection dir, Coord2D leftTop, Coord2D rightTop, Coord2D leftBottom, Coord2D rightBottom, int height, int width, YUV161616Pixel border, PixelInterpolation pi) {
   VisionLabPINVOKE.Warp__SWIG_25(YUV161616Image.getCPtr(src), YUV161616Image.getCPtr(dest), (int)dir, Coord2D.getCPtr(leftTop), Coord2D.getCPtr(rightTop), Coord2D.getCPtr(leftBottom), Coord2D.getCPtr(rightBottom), height, width, YUV161616Pixel.getCPtr(border), (int)pi);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public static void FastFourierT(ComplexDoubleImage image, TransformDirection dir) {
   VisionLabPINVOKE.FastFourierT__SWIG_2(ComplexDoubleImage.getCPtr(image), (int)dir);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 public static string TransformDirectionToStr(TransformDirection dir) {
   string ret = VisionLabPINVOKE.TransformDirectionToStr((int)dir);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Beispiel #52
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            Task.Run(() =>
            {
                if (beatmap?.Beatmap == null)
                    //todo: we may need to display some default text here (currently in the constructor).
                    return;

                BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
                title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode);
                artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode);
            });

            MusicControllerBackground newBackground;

            (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate
            {

                Add(newBackground);

                switch (direction)
                {
                    case TransformDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                        backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic);
                        break;
                    case TransformDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                        backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic);
                        break;
                }

                backgroundSprite.Expire();
                backgroundSprite = newBackground;
            });
        }
 public static void FFT1d(int N, SWIGTYPE_p_std__complexT_double_t tab, TransformDirection dir) {
   VisionLabPINVOKE.FFT1d__SWIG_2(N, SWIGTYPE_p_std__complexT_double_t.getCPtr(tab), (int)dir);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
 }
 /// <summary>
 /// Makes the FFT full.
 /// </summary>
 /// <param name="functionVector">The function vector.</param>
 /// <param name="direction">The direction.</param>
 /// <returns></returns>
 public static Complex[] MakeFFT(Complex[] functionVector, TransformDirection direction)
 {
     Complexibility = 0;
     var values = MakeFFTRecursive(functionVector, direction);
     FFTReorder(values);
     return values;
 }
 /// <summary>
 /// Creates a new managed transform instance, reading necessary
 /// setting values from the provided <see cref="ISymmetricAlgorithm" />
 /// instance.
 /// </summary>
 /// <param name="algorithm">
 /// A <see cref="ISymmetricAlgorithm" /> instance from which to take
 /// setting values.
 /// </param>
 /// <param name="rgbIv">
 /// The initialization vector to use.
 /// </param>
 /// <param name="transformDirection">
 /// The direction of the transform (encryption or decryption).
 /// </param>
 /// <param name="endianness">
 /// The endianness convention for the algorithm.
 /// </param>
 protected ManagedTransformBase(ISymmetricAlgorithm algorithm, byte[] rgbIv, TransformDirection transformDirection, Endianness endianness)
 {
     Endianness = endianness;
     _bytesToWords = endianness == Endianness.Little
                         ? (BytesToWords)Utils.BytesToWordsLittleEndian
                         : Utils.BytesToWordsBigEndian;
     _writeWordsIntoBytes = endianness == Endianness.Little
                         ? (WriteWordsIntoBytes)Utils.WriteWordsIntoBytesLittleEndian
                         : Utils.WriteWordsIntoBytesBigEndian;
     PaddingMode = algorithm.Padding;
     BlockSizeBytes = algorithm.BlockSize >> 3;
     Mode = algorithm.ExtendedMode;
     NonceCombinationMode = algorithm.NonceCombinationMode;
     _registerShiftSize = algorithm.RegisterShiftSize;
     _feedbackValue = new byte[BlockSizeBytes];
     _iv = new byte[BlockSizeBytes];
     if (rgbIv != null)
     {
         rgbIv.CopyTo(_feedbackValue, 0);
         rgbIv.CopyTo(_iv, 0);
         if (Mode == ExtendedCipherMode.CTR)
         {
             switch (NonceCombinationMode)
             {
                 case NonceCombinationMode.Concatenate:
                     _counterSize = BlockSizeBytes - rgbIv.Length;
                     _counter = new byte[_counterSize];
                     break;
                 case NonceCombinationMode.Xor:
                     _counterSize = BlockSizeBytes;
                     _counter = new byte[_counterSize];
                     break;
                 case NonceCombinationMode.Add:
                     _counterSize = BlockSizeBytes;
                     _counter = (byte[])_feedbackValue.Clone();
                     break;
             }
             _initial = true;
         }
     }
     _transformDirection = transformDirection;
 }
Beispiel #56
0
 static extern Int32 gimp_drawable_transform_scale(Int32 drawable_ID,
     double x0,
     double y0,
     double x1,
     double y1,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample,
     int recursion_level,
     bool clip_result);
Beispiel #57
0
 /// <summary>
 ///		returns the symmetric engine and creates the encyptor/decryptor
 /// </summary>
 /// <param name="encrypt">whether to return a encrpytor or decryptor</param>
 /// <returns>ICryptoTransform</returns>
 private ICryptoTransform GetEncryptionTransform(TransformDirection direction)
 {
     if (m_bCalculateNewKeyAndIV)
         CalculateNewKeyAndIV();
     if (direction == TransformDirection.Encrypt)
         return GetEncryptionAlgorithm().CreateEncryptor(m_Key, m_IV);
     else
         return GetEncryptionAlgorithm().CreateDecryptor(m_Key, m_IV);
 }
Beispiel #58
0
        /// <summary>
        ///		performs the actual enc/dec.
        /// </summary>
        /// <param name="inputBytes">input byte array</param>
        /// <param name="Encrpyt">wheather or not to perform enc/dec</param>
        /// <returns>byte array output</returns>
        private byte[] Transform(byte[] inputBytes, TransformDirection direction)
        {
            //get the correct transform
            ICryptoTransform transform = GetEncryptionTransform(direction);

            //memory stream for output
            MemoryStream memStream = new MemoryStream();

            try
            {
                //setup the cryption - output written to memstream
                CryptoStream cryptStream = new CryptoStream(memStream, transform, CryptoStreamMode.Write);

                //write data to cryption engine
                cryptStream.Write(inputBytes, 0, inputBytes.Length);

                //we are finished
                cryptStream.FlushFinalBlock();

                //get result
                byte[] output = memStream.ToArray();

                //finished with engine, so close the stream
                cryptStream.Close();

                return output;
            }
            catch (Exception e)
            {
                //throw an error
                throw new Exception("Error in symmetric engine. Error : " + e.Message, e);
            }
        }
Beispiel #59
0
 /// <summary>
 /// Scale the image with a given factor and interpolation.
 /// </summary>
 /// <remarks>
 /// If there is an buffer, it gets flushed before scaling.
 /// </remarks>
 /// <param name="factor">Resize factor (< 1.0 = downscale, >1.0 =
 /// upscale)</param>
 /// <param name="interpolation">Interpolation type</param>
 /// <param name="direction">Scale direction (forward = scale by factor,
 /// backward = scale by 1/factor)</param>
 public void scale(double factor, InterpolationType interpolation,
     TransformDirection direction)
 {
     bool restoreBuffer = _imageBuffer != null;
     if (restoreBuffer) {
         flushBuffer();
     }
     double newHeight = Height * factor;
     double newWidth = Width * factor;
     Image.UndoGroupStart();
     Drawable.TransformScale(0, 0, newWidth, newHeight,
         direction, interpolation, false, 1, false);
     Image.ResizeToLayers();
     Image.UndoGroupEnd();
     _drawable = Image.ActiveDrawable;
     _rectangle = Drawable.MaskBounds;
     if (restoreBuffer) {
         initBuffer();
     }
 }
Beispiel #60
0
 static extern Int32 gimp_drawable_transform_2d(Int32 drawable_ID,
     double source_x,
     double source_y,
     double scale_x,
     double scale_y,
     double angle,
     double dest_x,
     double dest_y,
     TransformDirection transform_direction,
     InterpolationType interpolation,
     bool supersample,
     int recursion_level,
     bool clip_result);