static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Add images to apply watermarks to
            waterMarker.AddInputFile("my_sample_image2.jpg", "my_sample_image2_output.jpg");
            waterMarker.AddInputFile("my_sample_image3.jpg", "my_sample_image3_output.jpg");

            // Create new watermark
            TextFitsPage preset = new TextFitsPage();

            // Set watermark text
            preset.Text = "Bytescout Watermarking";

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);


            // Apply watermarks
            waterMarker.Execute();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Add images to apply watermarks to
            waterMarker.AddInputFile("image1.jpg", "image1_watermarked.jpg");
            waterMarker.AddInputFile("image2.jpg", "image2_watermarked.jpg");
            waterMarker.AddInputFile("image3.jpg", "image3_watermarked.jpg");

            // Create new watermark
            TextFitsPage preset = new TextFitsPage();

            // Set watermark text
            preset.Text = "My Watermark (c) Me 2010";

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Add Progress event handler
            waterMarker.Progress += new ProgressEventHandler(waterMarker_Progress);

            // Apply watermarks
            waterMarker.Execute();

            Console.WriteLine();
            Console.WriteLine("Hit any key...");
            Console.ReadKey();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            StampFitsPageDiagonal preset = new StampFitsPageDiagonal();

            // Set stamp type
            preset.ImageFile = "[APPROVED]";

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            DateAndTime preset = new DateAndTime();

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Set output format
            waterMarker.OutputOptions.ImageFormat = OutputFormats.JPEG;

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            LogoWithText preset = new LogoWithText();

            // Select image file
            preset.ImageFile = "mylogo.png";

            // Set text transparency
            preset.Transparency = 40;

            // Set watermark placement
            preset.Placement = WatermarkPlacement.MiddleCenter;

            // Set text
            preset.Text = "Bytescout Watermarking";

            // Set text location
            preset.TextLocation = TextLocation.Bottom;

            // Set text color
            preset.TextColor = Color.Black;

            // Set text Alignment
            preset.TextAlignment = TextAlignment.Center;

            // Set text font
            preset.Font = new WatermarkFont("Tahoma", FontStyle.Regular, FontSizeType.Points, 20);

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Set output format
            waterMarker.OutputOptions.ImageFormat = OutputFormats.JPEG;

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            TextAnnotation preset = new TextAnnotation();

            // Set radius of the corners of the rectangle
            preset.Radius = 30;

            // Set text color
            preset.TextColor = Color.Black;

            // Set annotation background color
            preset.BackgroundColor = Color.White;

            // Set annotation background transparency
            preset.BackgroundTransparency = 40;

            // Set text
            preset.Text = "Bytescout Watermarking";

            // Set watermark font
            preset.Font = new WatermarkFont("Tahoma", FontStyle.Regular, FontSizeType.Points, 25);

            // Set watermark placement
            preset.Placement = WatermarkPlacement.MiddleCenter;

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Set output format
            waterMarker.OutputOptions.ImageFormat = OutputFormats.JPEG;

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 7
0
        public void TestBinaryWatermark()
        {
            BinaryWatermark mark = new BinaryWatermark(new byte[] { 1, 2, 3, 4 });

            Watermarker.EmbedWatermark(file, mark, "password", "results/BinaryMark.png");

            PNGFile file2 = new PNGFile("results/BinaryMark.png");

            BinaryWatermark extract = (BinaryWatermark)Watermarker.ExtractWatermark(file2, "password");

            Expect(extract.data, Is.EqualTo(new byte[] { 1, 2, 3, 4 }));
        }
Exemplo n.º 8
0
        public void TestTextWatermark()
        {
            TextWatermark mark = new TextWatermark("This is a test");

            Watermarker.EmbedWatermark(file, mark, "password", "results/TextMark.png");

            PNGFile file2 = new PNGFile("results/TextMark.png");

            TextWatermark extract = Watermarker.ExtractWatermark <TextWatermark>(file2, "password");

            Expect(extract.Text, Is.EqualTo("This is a test"));
        }
Exemplo n.º 9
0
        private void StoreTooMuchSR()
        {
            int size = file.EstimatedSolomonReedStorage + 1;

            byte[] data = new byte[size];
            for (var x = 0; x < size; x++)
            {
                data[x] = 0xFF;
            }

            Watermarker.EmbedWatermark(file, new BinaryWatermark(data), "password", "results/StorageCalc.png");
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            TextAnnotation preset = new TextAnnotation();

            // Set text with macros
            // complete list of available macros please see in the SDK documentation
            preset.Text = @"Date Time: {{LOCAL_DATE_LONG}} {{LOCAL_TIME}} " +
                          "\nFilename: {{FILENAME}}\n" +
                          "Manufacturer: {{EXIF_EQUIPMENT_MANUFACTURER}}\n" +
                          "Model: {{EXIF_EQUIPMENT_MODEL}}\n" +
                          "Software: {{EXIF_SOFTWARE_USED}}\n" +
                          "Date/Time: {{EXIF_ORIGINAL_DATE}}\n" +
                          "Exposure Time: {{EXIF_EXPOSURE_TIME}} sec\n" +
                          "Exposure Program: {{EXIF_EXPOSURE_PROGRAM}}\n" +
                          "Exposure Bias: {{EXIF_EXPOSURE_BIAS}} EV\n" +
                          "F Number: F {{EXIF_F_NUMBER}}\n" +
                          "ISO Speed Rating: ISO {{EXIF_ISO_SPEED}}\n" +
                          "Flash: {{EXIF_FLASH}}\n" +
                          "Focal Length: {{EXIF_FOCAL_LENGTH}} mm\n" +
                          "Metering Mode: {{EXIF_METERING_MODE}}";


            // Set watermark font
            preset.Font = new WatermarkFont("Tahoma", FontStyle.Regular, FontSizeType.Percents, 2); // set font size to 2% of the image size

            waterMarker.OutputOptions.OutputDirectory = ".";
            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 11
0
        public void TestFileWatermark()
        {
            FileWatermark mark = new FileWatermark(@"TestFile.txt");

            Watermarker.EmbedWatermark(file, mark, "password", "results/FileMark.png");


            PNGFile file2 = new PNGFile("results/FileMark.png");

            FileWatermark extract = (FileWatermark)Watermarker.ExtractWatermark(file2, "password");

            Expect(extract.extension, Is.EqualTo(".txt"));
            Expect(extract.fileData, Is.EqualTo(System.Text.Encoding.UTF8.GetBytes("This is a test file!")));
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = MapPath("my_sample_image.jpg");

            // Create sample input stream
            Stream inputStream = new FileStream(inputFilePath, FileMode.Open);
            // Create image from stream
            Image image = new Bitmap(inputStream);

            // Add image to apply watermarks to
            waterMarker.AddInputFile(image);

            // Create watermark
            TextFitsPage preset = new TextFitsPage();

            preset.Text         = "Bytescout Watermarking";
            preset.TextColor    = Color.Aqua;
            preset.Transparency = 25;

            // Add watermark to Watermarker
            waterMarker.AddWatermark(preset);

            // Clear http output
            Response.Clear();
            // Set the content type to JPEG
            Response.ContentType = "image/jpeg";
            // Add content type header
            Response.AddHeader("Content-Type", "image/jpeg");
            // Set the content disposition
            Response.AddHeader("Content-Disposition", "inline;filename=my_sample_image.jpg");

            // Set Response.OutputStream as result image destination
            waterMarker.OutputOptions.OutputStream = Response.OutputStream;

            // Execute watermarking
            waterMarker.Execute(0);

            // Cleanup
            image.Dispose();
            inputStream.Dispose();

            Response.End();
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            TextFitsPageDiagonal preset = new TextFitsPageDiagonal();

            // Set watermark text
            preset.Text = "Bytescout Watermarking";

            // Set watermark font
            preset.Font = new WatermarkFont("Tahoma", FontStyle.Regular, FontSizeType.Points, 30);

            // Set watermark text color
            preset.TextColor = Color.Black;

            // Set text transparency
            preset.Transparency = 40;

            // Set watermark orientation
            preset.Orientation = DiagonalOrientation.FromTopLeftToBottomRight;

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Set output format
            waterMarker.OutputOptions.ImageFormat = OutputFormats.JPEG;

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 14
0
        public void TestStorageCalculation()
        {
            int size = file.EstimatedStorage;

            byte[] data = new byte[size];
            for (var x = 0; x < size; x++)
            {
                data[x] = 0xFF;
            }
            //Storage estimates are only valid if ReedSolomon isn't being used.
            Watermarker.ReedSolomonProtection = false;

            Watermarker.EmbedWatermark(file, new BinaryWatermark(data), "password", "results/StorageCalc.png");

            Assert.That(StoreTooMuch, Throws.Exception);
        }
Exemplo n.º 15
0
        public void TestScrambling()
        {
            TextWatermark mark = new TextWatermark("This is a test");


            Watermarker.EmbedWatermark(file, mark, "password", "results/Scrambling.png");


            PNGFile file2 = new PNGFile("results/TextMark.png");

            TextWatermark extracted = Watermarker.ExtractWatermark <TextWatermark>(file2, "password");


            extracted = Watermarker.ExtractWatermark <TextWatermark>(file2, "foobar");

            Expect(extracted, Is.Null);
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            LogoImage preset = new LogoImage();

            // Select image file
            preset.ImageFile = "mylogo.png";

            // Set text transparency
            preset.Transparency = 40;

            // Set watermark placement
            preset.Placement = WatermarkPlacement.MiddleCenter;

            // Set scale
            preset.Scale = 2.0f;

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Set output format
            waterMarker.OutputOptions.ImageFormat = OutputFormats.JPEG;

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";


            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Allow resize
            waterMarker.OutputOptions.Resize = true;

            // Allow to enlarge image
            waterMarker.OutputOptions.DontEnlargeSmallImages = false;

            // Set resize type to pixels
            waterMarker.OutputOptions.ResizeType = ResizeType.Pixels;

            // Fit to width
            waterMarker.OutputOptions.ResizeFitWithin = FitWithin.WidthOnly;

            // Set width
            waterMarker.OutputOptions.ResizeWidthInPixels = 600;

            // Set height
            waterMarker.OutputOptions.ResizeHeightInPixels = 20;


            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";


            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";


            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);


            // Allow resize
            waterMarker.OutputOptions.Resize = true;

            // Set resize type to percentage
            waterMarker.OutputOptions.ResizeType = ResizeType.Actual;

            // Set units type
            waterMarker.OutputOptions.ResizeActualUnits = ActualSizeUnits.inches;

            // Set image width
            waterMarker.OutputOptions.ResizeWidthInUnits = 1.5f;

            // Set image height
            waterMarker.OutputOptions.ResizeHeightInUnits = 2.0f;

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Apply watermarks
            waterMarker.Execute();


            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 19
0
        public void TestCompositeWatermark()
        {
            EncryptedWatermark.Algorithm = aes;

            CompositeWatermark comp  = new CompositeWatermark();
            TextWatermark      mark1 = new TextWatermark("This is mark #1");
            TextWatermark      mark2 = new TextWatermark("This is mark #2");

            EncryptedWatermark enc = new EncryptedWatermark(mark1, "supersecret");

            comp.AddWatermark(mark1);
            comp.AddWatermark(mark2);
            Expect(comp.Watermarks.Count, Is.EqualTo(2));

            comp.AddWatermark(enc);
            Expect(comp.Watermarks.Count, Is.EqualTo(3));

            Watermarker.EmbedWatermark(file, comp, "password", "results/CompositeMark.png");


            PNGFile file2 = new PNGFile("results/CompositeMark.png");

            CompositeWatermark extract = (CompositeWatermark)Watermarker.ExtractWatermark(file2, "password");


            System.Collections.Generic.List <Watermark> marks = extract.Watermarks;

            Expect(marks.Count, Is.EqualTo(3));

            Assert.IsInstanceOf <TextWatermark>(marks[0]);

            Assert.IsInstanceOf <TextWatermark>(marks[1]);

            Assert.IsInstanceOf <EncryptedWatermark>(marks[2]);



            ((EncryptedWatermark)marks[2]).Decrypt("supersecret");

            Expect(((TextWatermark)marks[0]).Text, Is.EqualTo("This is mark #1"));
            Expect(((TextWatermark)marks[1]).Text, Is.EqualTo("This is mark #2"));
            Expect(((EncryptedWatermark)marks[2]).Decrypt <TextWatermark>("supersecret").Text, Is.EqualTo("This is mark #1"));
        }
Exemplo n.º 20
0
        public void TestEncryptedWatermark()
        {
            EncryptedWatermark.Algorithm = aes;

            TextWatermark      mark      = new TextWatermark("This should be encrypted");
            EncryptedWatermark encrypted = new EncryptedWatermark(mark, "super-secret");

            Watermarker.EmbedWatermark(file, encrypted, "password", "results/EncryptedMark.png");


            PNGFile            file2   = new PNGFile("results/EncryptedMark.png");
            EncryptedWatermark extract = (EncryptedWatermark)Watermarker.ExtractWatermark(file2, "password");

            mark = extract.Decrypt <TextWatermark>("super-secret");

            Expect(mark, Is.Not.Null);

            Expect(mark.Text, Is.EqualTo("This should be encrypted"));
        }
Exemplo n.º 21
0
        public void TestDoubleEncrypt()
        {
            EncryptedWatermark.Algorithm = aes;

            TextWatermark      mark = new TextWatermark("This will be encrypted twice");
            EncryptedWatermark enc1 = new EncryptedWatermark(mark, "password1");
            EncryptedWatermark enc2 = new EncryptedWatermark(enc1, "password2");

            Watermarker.EmbedWatermark(file, enc2, "password", "results/DoubleEncrypt.png");

            PNGFile file2 = new PNGFile("results/DoubleEncrypt.png");

            EncryptedWatermark extract = Watermarker.ExtractWatermark <EncryptedWatermark>(file, "password");

            extract = extract.Decrypt <EncryptedWatermark>("password2");


            mark = extract.Decrypt <TextWatermark>("password1");

            Expect(mark.Text, Is.EqualTo("This will be encrypted twice"));
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            TiledTextDiagonal preset = new TiledTextDiagonal();

            // Set text
            preset.Text = "Sample watermark text";

            // Set font size
            preset.Font.Style = FontStyle.Bold;
            preset.Font.Size  = 3;

            preset.Transparency = 15;

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 23
0
        public void TestSeperateMarks()
        {
            // This will only pass if the marks do not overlap on any pixels.

            TextWatermark text1 = new TextWatermark("text1");
            TextWatermark text2 = new TextWatermark("text2");

            Watermarker.EmbedWatermark(file, text1, "password", "results/Embed1.png");

            file = new PNGFile("results/Embed1.png");

            Watermarker.EmbedWatermark(file, text2, "foobar", "results/Embed2Marks.png");

            PNGFile file2 = new PNGFile("results/Embed2Marks.png");

            TextWatermark extract1 = (TextWatermark)Watermarker.ExtractWatermark(file2, "password");

            TextWatermark extract2 = (TextWatermark)Watermarker.ExtractWatermark(file2, "foobar");

            Expect(extract1.Text, Is.EqualTo("text1"));
            Expect(extract2.Text, Is.EqualTo("text2"));
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";

            foreach (string stampType in Stamp.PresetImages)
            {
                // Set output file title
                string outputFilePath = "my_sample_output_" + stampType + ".jpg";

                // Add image to apply watermarks to
                waterMarker.AddInputFile(inputFilePath, outputFilePath);

                // Set output directory
                waterMarker.OutputOptions.OutputDirectory = ".";

                // Create new watermark
                Stamp preset = new Stamp();

                // Set stamp type
                preset.ImageFile = stampType;

                // Add watermark to watermarker
                waterMarker.AddWatermark(preset);

                // Apply watermarks
                waterMarker.Execute();

                // Clear all settings
                waterMarker.Clear();
            }
        }
Exemplo n.º 25
0
        public void TestLongRSWatermark()
        {
            byte[] data = new byte[300];
            for (var x = 0; x < 300; x++)
            {
                data[x] = (byte)(x % 17);
            }

            BinaryWatermark binMark = new BinaryWatermark(data);

            Watermarker.ReedSolomonProtection = true;

            Watermarker.EmbedWatermark(file, binMark, "password", "results/LongRS.png");

            PNGFile file2 = new PNGFile("results/LongRS.png");

            BinaryWatermark binMark2 = Watermarker.ExtractWatermark <BinaryWatermark>(file2, "password");

            for (var x = 0; x < binMark2.data.Length; x++)
            {
                Expect(binMark2.data[x], Is.EqualTo(binMark.data[x]));
            }
        }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            LogoWithText preset = new LogoWithText();

            // Select image file
            preset.ImageFile = "mylogo.png";

            // Set text
            preset.Text = "Bytescout Watermarking";

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";


            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Allow to override resolution
            waterMarker.OutputOptions.OverrideResolution = true;

            // Set vertical resolution
            waterMarker.OutputOptions.VerticalResolution = 300;

            // Set horizontal resolution
            waterMarker.OutputOptions.HorizontalResolution = 300;


            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";


            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            SimpleText preset = new SimpleText();

            // Set watermark text
            preset.Text = "Bytescout Watermarking";

            // Set watermark font
            preset.Font = new WatermarkFont("Tahoma", FontStyle.Regular, FontSizeType.Points, 30);

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";


            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);


            // Allow resize
            waterMarker.OutputOptions.Resize = true;

            // Set resize type to percentage
            waterMarker.OutputOptions.ResizeType = ResizeType.Percentage;

            // Reduce image by 1/2
            waterMarker.OutputOptions.ResizePercentage = 50;

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";


            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Exemplo n.º 30
0
        public ActionResult WaterMarkImage(HttpPostedFileBase fileToUpload)
        {
            using (Image image = Image.FromStream(fileToUpload.InputStream, true, false))
            {
                string      name           = Path.GetFileNameWithoutExtension(fileToUpload.FileName);
                var         ext            = Path.GetExtension(fileToUpload.FileName);
                string      myfile         = name + ext;
                var         saveImagePath  = Path.Combine(Server.MapPath("~/ImgWatermark"), myfile);
                Image       watermarkImage = Image.FromFile(Server.MapPath("/Img/watermarklogo.png"));
                Watermarker objWatermarker = new Watermarker(image);
                for (int i = 0; i < image.Height; i++)
                {
                    for (int j = 0; j < image.Width; j++)
                    {
                        // Set the properties for the logo
                        objWatermarker.Position         = WatermarkPosition.Absolute;
                        objWatermarker.PositionX        = j;
                        objWatermarker.PositionY        = i;
                        objWatermarker.Margin           = new Padding(20);
                        objWatermarker.Opacity          = 0.5f;
                        objWatermarker.TransparentColor = Color.White;
                        objWatermarker.ScaleRatio       = 3;
                        // Draw the logo
                        objWatermarker.DrawImage(watermarkImage);
                        //Draw the Text
                        //objWatermarker.DrawText("WaterMarkDemo")

                        j = j + 400; // watermark image width
                    }
                    i = i + 120;     //
                }
                objWatermarker.Image.Save(saveImagePath);

                return(RedirectToAction("Index", new { imgName = myfile }));
            }
        }