Пример #1
0
        /// <summary>
        /// Embeds a given watermark into a PNG file and saves the result.
        /// </summary>
        /// <param name="file">PNGFile to use in the watermarking process.</param>
        /// <param name="mark">The watermark to embed.</param>
        /// <param name="password">A password for the embedding process</param>
        /// <param name="outputPath">Location of the saved file.</param>
        public static void EmbedWatermark(PNGFile file, Watermark mark, string password, string outputPath)
        {
            Rfc2898DeriveBytes bytes = new Rfc2898DeriveBytes(password, new byte[] { 112, 52, 63, 42, 180, 121, 53, 27 }, 1000);

            PNGScrambler scrambler = new PNGScrambler(file, bytes.GetBytes(16), bytes.GetBytes(8));

            byte[] markBytes = mark.GetBytes();

            if (ReedSolomonProtection == false)
            {
                EmbedData(markBytes, scrambler);
            }
            else
            {
                markBytes = EncodeWithReedSolomon(markBytes);
                EmbedData(markBytes, scrambler);
            }

            file.SaveAs(outputPath);
        }