Results 1 to 22 of 22

Thread: need help convert code and run on vb.net

Threaded View

  1. #2
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,500

    Re: need help convert code and run on vb.net

    Hi,

    I think I'd try this:
    vb.NET Code:
    1. Syntax
    2. Visual Basic (Declaration)
    3. Public Class InputImageFile _
    4.     Implements IDisposable
    5. Examples
    6. The following example demonstrates usage of InputImageFile class. The code collects all JPEG images from the specifed directory and prepares them for watermarking.
    7.      
    8. try
    9. {
    10.     Watermarker w = new Watermarker("demo", "demo");
    11.     List<InputImageFile> inputImages = new List<InputImageFile>();
    12.  
    13.     string[] imageFiles = System.IO.Directory.GetFiles("c:\\Family\\Photo\\unsorted", "*.jpg",
    14.         System.IO.SearchOption.AllDirectories);
    15.  
    16.     foreach (string filename in imageFiles)
    17.     {
    18.         w.InputImages.Add(new InputImageFile(filename, Path.GetFileName(filename));
    19.     }
    20. }
    21. catch (System.Exception e)
    22. {
    23.     MessageBox.Show(e.Message);
    24. }
    25.  
    26.  
    27. Syntax
    28. Visual Basic (Declaration)
    29. Public Class TextWatermark _
    30.     Inherits WatermarkBase
    31.  
    32. Examples
    33. The following example demonstrates usage of TextWatermark class.
    34.      
    35. try
    36. {
    37.     Watermarker w = new Watermarker("demo", "demo");
    38.     w.AddInputFile("c:\\temp\\input\\image1.jpg", "image1_watermarked.jpg");
    39.  
    40.     TextWatermark twm = new TextWatermark()
    41.     With twm
    42.          .Text = "Copyright © John Doe, 2008";
    43.          .Font = new WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2);
    44.          .TextColor = Color.Red;
    45.          .Transparency = 40;
    46.          .Alignment = TextAlignment.Center;
    47.          .Placement = WatermarkPlacement.BottomRight;
    48.          .Margins = new WatermarkMargins(20, 20, 20, 20);
    49.     End With
    50.     w.AddWatermark(twm)
    51.     w.OutputOptions.OutputDirectory = "c:\\temp\\output";
    52.     w.Execute();
    53. }
    54. catch (System.Exception e)
    55. {
    56.     MessageBox.Show(e.Message);
    57. }

    Poppa
    Last edited by Poppa Mintin; Aug 19th, 2021 at 05:18 PM. Reason: Typo
    Along with the sunshine there has to be a little rain sometime.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width