Пример #1
0
        public MainPage()
        {
            Config = new FFmpegInteropConfig();

            this.InitializeComponent();

            // Show the control panel on startup so user can start opening media
            Splitter.IsPaneOpen      = true;
            AutoDetect.IsOn          = true;
            VideoEffectConfiguration = new VideoEffectConfiguration();

            mediaPlayer = new MediaPlayer();
            mediaPlayer.AudioCategory = MediaPlayerAudioCategory.Movie;
            mediaPlayer.MediaOpened  += MediaPlayer_MediaOpened;
            mediaPlayer.MediaFailed  += MediaPlayer_MediaFailed;
            mediaPlayerElement.SetMediaPlayer(mediaPlayer);

            // optionally check for recommended ffmpeg version
            //FFmpegVersionInfo.CheckRecommendedVersion();

            CodecChecker.CodecRequired += CodecChecker_CodecRequired;

            // populate character encodings
            cbEncodings.ItemsSource = CharacterEncoding.GetCharacterEncodings();

            CoreWindow.GetForCurrentThread().KeyDown += MainPage_KeyDown;
        }
Пример #2
0
 public override void Configure(XmlElement element)
 {
     base.Configure(element);
     RegexPattern = XmlUtilities.GetAttribute(element, "pattern", RegexPattern);
     RegexOptions = XmlUtilities.GetAttribute(element, "regexOptions", RegexOptions);
     Encoding     = XmlUtilities.GetAttribute(element, "encoding", Encoding);
 }
 public override void Configure(XmlElement element)
 {
     base.Configure(element);
     RegexPattern = XmlUtilities.GetAttribute(element, "pattern", RegexPattern);
     RegexOptions = XmlUtilities.GetAttribute(element, "regexOptions", RegexOptions);
     Encoding = XmlUtilities.GetAttribute(element, "encoding", Encoding);
 }
Пример #4
0
 public static byte[] GetBytes(string data, int limit, Languages language)
 {
     data = CharacterEncoding.ConvertToLanguage(data, language);
     byte[] finalData = new byte[limit * 2];
     for (int i = 0; i < data.Length; i++)
     {
         BigEndian.WriteUInt16(data[i], finalData, i * 2);
     }
     return(finalData);
 }
Пример #5
0
        protected override void BeforeGenerateValues(Project project, Column column, int count, int nullCount)
        {
            CharacterEncoding encoding = Encoding;

            if (!IsUnicode(column))
            {
                encoding = CharacterEncoding.ASCII;
            }

            _engine    = new RexEngine(encoding, -1);
            _generator = _engine.GenerateMembers(RegexOptions, count, RegexPattern).GetEnumerator();
        }
Пример #6
0
        public MainPage()
        {
            Config = new FFmpegInteropConfig();

            this.InitializeComponent();

            // Show the control panel on startup so user can start opening media
            Splitter.IsPaneOpen = true;

            // optionally check for recommended ffmpeg version
            //FFmpegVersionInfo.CheckRecommendedVersion();

            // populate character encodings
            cbEncodings.ItemsSource = CharacterEncoding.GetCharacterEncodings();
        }
Пример #7
0
        /// <summary>
        /// Encodes a message into the loaded image.
        /// </summary>
        /// <param name="message"></param>
        public void EncodeMessage(string message, Stream outStream)
        {
            if (!IsImageLoaded)
            {
                throw new InvalidOperationException("No source image has been loaded.");
            }

            byte[] messageBytes = CharacterEncoding.GetBytes(message);

            if (messageBytes.Length > AvailableMessageBytes)
            {
                throw new InvalidOperationException(
                          string.Format("Unable to fit message. Message is {0} bytes, and only {1} bytes are available.",
                                        messageBytes.Length,
                                        AvailableMessageBytes)
                          );
            }

            MessagePosition     = 0;
            EndOfMessageReached = false;

            using (FastBitmap bitmap = new FastBitmap(SourceImage.Image))
            {
                for (int y = 0; y < bitmap.Height; y++)
                {
                    for (int x = 0; x < bitmap.Width; x++)
                    {
                        WriteBytesToPixel(bitmap, messageBytes, x, y);

                        if (EndOfMessageReached)
                        {
                            break;
                        }
                    }


                    if (EndOfMessageReached)
                    {
                        break;
                    }
                }
            }


            SourceImage.Save(outStream);
        }
Пример #8
0
        public static byte[] GetBytes(string data, int limit, Languages language = Languages.English)
        {
            data = CharacterEncoding.ConvertToLanguage(data, language);
            byte[]   codeArray          = new byte[limit];
            string[] arrayFromCharArray = GBACharacterEncoding.CreateStringArrayFromCharArray(data.ToCharArray());
            int      index = 0;

            for (int i = 0; i < data.Length; i++)
            {
                string s = new string(data[i], 1);
                if (index != codeArray.Length)
                {
                    if (language == Languages.Japanese && japaneseTable.Any <KeyValuePair <byte, string> >((KeyValuePair <byte, string> u) => u.Value == s))
                    {
                        KeyValuePair <byte, string> keyValuePair = (from u in japaneseTable where u.Value == s select u).FirstOrDefault <KeyValuePair <byte, string> >();
                        codeArray[index] = keyValuePair.Key;
                        index++;
                    }
                    else if (language != Languages.Japanese && englishTable.Any <KeyValuePair <byte, string> >((KeyValuePair <byte, string> u) => u.Value == s))
                    {
                        KeyValuePair <byte, string> keyValuePair = (from u in englishTable where u.Value == s select u).FirstOrDefault <KeyValuePair <byte, string> >();
                        codeArray[index] = keyValuePair.Key;
                        index++;
                    }

                    /*else {
                     *      codeArray[index] = 0;
                     * }
                     * index++;*/
                }
                else
                {
                    break;
                }
            }
            if (index < limit)
            {
                for (; index < limit; index++)
                {
                    codeArray[index] = byte.MaxValue;
                }
            }
            return(codeArray);
        }
Пример #9
0
        /// <summary>
        ///     Automatically detects the Encoding type of a given byte buffer.
        /// </summary>
        /// <param name="buffer">The byte buffer.</param>
        /// <param name="size">The size of the byte buffer.</param>
        /// <returns>The Encoding type or Encoding.None if unknown.</returns>
        public CharacterEncoding DetectEncoding(byte[] buffer, int size)
        {
            // First check if we have a BOM and return that if so
            CharacterEncoding encoding = CheckBom(buffer, size);

            if (encoding != CharacterEncoding.None)
            {
                return(encoding);
            }

            // Now check for valid UTF8
            encoding = CheckUtf8(buffer, size);
            if (encoding != CharacterEncoding.None)
            {
                return(encoding);
            }

            // Now try UTF16
            encoding = CheckUtf16NewlineChars(buffer, size);
            if (encoding != CharacterEncoding.None)
            {
                return(encoding);
            }

            encoding = CheckUtf16Ascii(buffer, size);
            if (encoding != CharacterEncoding.None)
            {
                return(encoding);
            }

            // ANSI or None (binary) then
            if (!DoesContainNulls(buffer, size))
            {
                return(CharacterEncoding.Ansi);
            }

            // Found a null, return based on the preference in null_suggests_binary_
            return(_nullSuggestsBinary ? CharacterEncoding.None : CharacterEncoding.Ansi);
        }
Пример #10
0
        /// <summary>
        ///     Gets the BOM length for a given Encoding mode.
        /// </summary>
        /// <param name="encoding"></param>
        /// <returns>The BOM length.</returns>
        public static int GetBomLengthFromEncodingMode(CharacterEncoding encoding)
        {
            int length;

            switch (encoding)
            {
            case CharacterEncoding.Utf16BeBom:
            case CharacterEncoding.Utf16LeBom:
                length = 2;
                break;

            case CharacterEncoding.Utf8Bom:
                length = 3;
                break;

            default:
                length = 0;
                break;
            }

            return(length);
        }
Пример #11
0
        public MainPage()
        {
            Config = new FFmpegInteropConfig();

            this.InitializeComponent();

            // Show the control panel on startup so user can start opening media
            Splitter.IsPaneOpen = true;
            AutoDetect.IsOn     = true;

            VideoEffectConfiguration = new VideoEffectConfiguration();

            // optionally check for recommended ffmpeg version
            //FFmpegVersionInfo.CheckRecommendedVersion();

            CodecChecker.CodecRequired += CodecChecker_CodecRequired;

            // populate character encodings
            cbEncodings.ItemsSource = CharacterEncoding.GetCharacterEncodings();

            this.KeyDown += MainPage_KeyDown;
        }
Пример #12
0
 private void CalculateAvailableMessageBytes()
 {
     AvailableMessageBytes      = (int)Math.Floor((double)ImageDataLength * ((double)EncodedBits / 8.0));
     AvailableMessageCharacters = CharacterEncoding.GetMaxCharCount(AvailableMessageBytes);
 }
Пример #13
0
 public RegexGenerator()
 {
     this.Encoding = CharacterEncoding.Unicode;
 }
Пример #14
0
 public override void MakeSchemaCompliant()
 {
     base.MakeSchemaCompliant();
     LanguageCode.MakeSchemaCompliant();
     CharacterEncoding.MakeSchemaCompliant();
 }
 public RegexGenerator()
 {
     this.Encoding = CharacterEncoding.Unicode;
 }