|
-
Aug 19th, 2021, 05:16 PM
#1
Re: need help convert code and run on vb.net
Hi,
I think I'd try this:
vb.NET Code:
Syntax
Visual Basic (Declaration)
Public Class InputImageFile _
Implements IDisposable
Examples
The following example demonstrates usage of InputImageFile class. The code collects all JPEG images from the specifed directory and prepares them for watermarking.
try
{
Watermarker w = new Watermarker("demo", "demo");
List<InputImageFile> inputImages = new List<InputImageFile>();
string[] imageFiles = System.IO.Directory.GetFiles("c:\\Family\\Photo\\unsorted", "*.jpg",
System.IO.SearchOption.AllDirectories);
foreach (string filename in imageFiles)
{
w.InputImages.Add(new InputImageFile(filename, Path.GetFileName(filename));
}
}
catch (System.Exception e)
{
MessageBox.Show(e.Message);
}
Syntax
Visual Basic (Declaration)
Public Class TextWatermark _
Inherits WatermarkBase
Examples
The following example demonstrates usage of TextWatermark class.
try
{
Watermarker w = new Watermarker("demo", "demo");
w.AddInputFile("c:\\temp\\input\\image1.jpg", "image1_watermarked.jpg");
TextWatermark twm = new TextWatermark()
With twm
.Text = "Copyright © John Doe, 2008";
.Font = new WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2);
.TextColor = Color.Red;
.Transparency = 40;
.Alignment = TextAlignment.Center;
.Placement = WatermarkPlacement.BottomRight;
.Margins = new WatermarkMargins(20, 20, 20, 20);
End With
w.AddWatermark(twm)
w.OutputOptions.OutputDirectory = "c:\\temp\\output";
w.Execute();
}
catch (System.Exception e)
{
MessageBox.Show(e.Message);
}
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.
-
Aug 19th, 2021, 10:15 PM
#2
Thread Starter
Lively Member
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
-
Aug 20th, 2021, 05:37 AM
#3
Re: need help convert code and run on vb.net
 Originally Posted by roy88
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.
-
Aug 20th, 2021, 09:21 AM
#4
Thread Starter
Lively Member
Re: need help convert code and run on vb.net
 Originally Posted by Poppa Mintin
Oh ! I'm sorry, I must've posted the wrong list.
Poppa
ok sir
-
Aug 20th, 2021, 10:57 AM
#5
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:
Sub main()
Try
Dim w As Watermarker = New Watermarker("demo", "demo")
Dim twm As TextWatermark = New TextWatermark
Dim imageFiles() As String = System.IO.Directory.GetFiles("C:\emp\input", "*.png", System.IO.SearchOption.AllDirectories)
For Each filename As String In imageFiles
w.AddInputFile(filename)
With twm
.Text = "Copyright John Doe, 2008"
.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
.TextColor = Color.Red
.Transparency = 40
.Alignment = TextAlignment.Center
.Placement = WatermarkPlacement.BottomRight
.Margins = New WatermarkMargins(20, 20, 20, 20)
End With
w.AddWatermark(twm)
w.OutputOptions.OutputDirectory = "c:\emp\output"
w.Execute()
Next
Catch e As System.Exception
MessageBox.Show(e.Message)
End Try
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.
-
Aug 24th, 2021, 07:00 AM
#6
Thread Starter
Lively Member
Re: need help convert code and run on vb.net
 Originally Posted by Poppa Mintin
My code was much the same as that which you have except:
vb.NET Code:
Sub main()
Try
Dim w As Watermarker = New Watermarker("demo", "demo")
Dim twm As TextWatermark = New TextWatermark
Dim imageFiles() As String = System.IO.Directory.GetFiles("C:\emp\input", "*.png", System.IO.SearchOption.AllDirectories)
For Each filename As String In imageFiles
w.AddInputFile(filename)
With twm
.Text = "Copyright John Doe, 2008"
.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
.TextColor = Color.Red
.Transparency = 40
.Alignment = TextAlignment.Center
.Placement = WatermarkPlacement.BottomRight
.Margins = New WatermarkMargins(20, 20, 20, 20)
End With
w.AddWatermark(twm)
w.OutputOptions.OutputDirectory = "c:\emp\output"
w.Execute()
Next
Catch e As System.Exception
MessageBox.Show(e.Message)
End Try
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|