Exemplo n.º 1
0
        internal string ReadText(ChannelUsage usage, bool returnFilteredText = true, bool useThreads = true)
        {
            var values = new bool[usage.GetTotaleUsage() * _inputData.Size];
            var usages = usage.GetUsages();

            var numThreads   = useThreads ? _inputData.Size >> _threadSizeModifier | 1 : 1;
            var threadLength = _inputData.Size / numThreads;

            var threads = new Thread[numThreads];

            for (var i = 0; i < numThreads; i++)
            {
                var reader = new ReaderThread(_inputData, usages, values, i * threadLength, threadLength);
                threads[i] = new Thread(reader.ReadBooleans);
                threads[i].Start();
            }

            foreach (var thread in threads)
            {
                thread.Join();
            }

            var bytes = BitOperators.BitsToBytes(values);
            var text  = Encoding.UTF8.GetString(bytes);

            return(returnFilteredText ? FindOriginalText(text) : text);
        }
Exemplo n.º 2
0
        public static int GetMaxCharCount(int width, int height, ChannelUsage usage)
        {
            const int startAndEndLength = 12;
            var       pixCount          = height * width;
            var       channelUsage      = usage.GetTotaleUsage();

            return(pixCount * channelUsage - startAndEndLength);
        }