Results 1 to 22 of 22

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

Hybrid View

  1. #1
    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.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

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

    dear Poppa Mintin,

    you gave me is still the original code from me.


    thanks
    roy88

  3. #3
    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

    Quote Originally Posted by roy88 View Post
    dear Poppa Mintin,

    you gave me is still the original code from me.


    thanks
    roy88
    Oh ! I'm sorry, I must've posted the wrong list.

    Poppa
    Along with the sunshine there has to be a little rain sometime.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

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

    Quote Originally Posted by Poppa Mintin View Post
    Oh ! I'm sorry, I must've posted the wrong list.

    Poppa
    ok sir

  5. #5
    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

    My code was much the same as that which you have except:
    vb.NET Code:
    1. Sub main()
    2.         Try
    3.  
    4.             Dim w As Watermarker = New Watermarker("demo", "demo")
    5.             Dim twm As TextWatermark = New TextWatermark
    6.             Dim imageFiles() As String = System.IO.Directory.GetFiles("C:\emp\input", "*.png", System.IO.SearchOption.AllDirectories)
    7.             For Each filename As String In imageFiles
    8.                 w.AddInputFile(filename)
    9.                 With twm
    10.                      .Text = "Copyright  John Doe, 2008"
    11.                      .Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
    12.                      .TextColor = Color.Red
    13.                      .Transparency = 40
    14.                      .Alignment = TextAlignment.Center
    15.                      .Placement = WatermarkPlacement.BottomRight
    16.                      .Margins = New WatermarkMargins(20, 20, 20, 20)
    17.                 End With
    18.                 w.AddWatermark(twm)
    19.                 w.OutputOptions.OutputDirectory = "c:\emp\output"
    20.                 w.Execute()
    21.             Next
    22.  
    23.         Catch e As System.Exception
    24.             MessageBox.Show(e.Message)
    25.         End Try
    26.     End Sub

    Poppa
    Last edited by Poppa Mintin; Aug 20th, 2021 at 10:58 AM. Reason: Typo
    Along with the sunshine there has to be a little rain sometime.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

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

    Quote Originally Posted by Poppa Mintin View Post
    My code was much the same as that which you have except:
    vb.NET Code:
    1. Sub main()
    2.         Try
    3.  
    4.             Dim w As Watermarker = New Watermarker("demo", "demo")
    5.             Dim twm As TextWatermark = New TextWatermark
    6.             Dim imageFiles() As String = System.IO.Directory.GetFiles("C:\emp\input", "*.png", System.IO.SearchOption.AllDirectories)
    7.             For Each filename As String In imageFiles
    8.                 w.AddInputFile(filename)
    9.                 With twm
    10.                      .Text = "Copyright  John Doe, 2008"
    11.                      .Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
    12.                      .TextColor = Color.Red
    13.                      .Transparency = 40
    14.                      .Alignment = TextAlignment.Center
    15.                      .Placement = WatermarkPlacement.BottomRight
    16.                      .Margins = New WatermarkMargins(20, 20, 20, 20)
    17.                 End With
    18.                 w.AddWatermark(twm)
    19.                 w.OutputOptions.OutputDirectory = "c:\emp\output"
    20.                 w.Execute()
    21.             Next
    22.  
    23.         Catch e As System.Exception
    24.             MessageBox.Show(e.Message)
    25.         End Try
    26.     End Sub

    Poppa
    dear sir,
    sorry for late reply. thank you
    thanks

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