Hidden Image/File Watermarking callable from VB .NET?

bmilano
05-19-2005, 12:58 PM
Hi,

I was wondering if anybody has seen or had experience with any software packages that do covert and/or overt file or image watermarking that are callable from VB .NET? There seem to be a number of very low-priced packages that do basic watermarking, such as Strong Arm and Easy Batch Watermark, but you need to use their GUI in all cases. I am instead looking for a COM or .NET object that I can call from a VB .NET program to do my watermarking of files and/or images.

Thanks in advance for any leads,
Bill

George7a
05-20-2005, 04:51 AM
Try this:

Private Sub setBanners(Optional page As Integer)

Dim pageWidth As Double, pageHeight As Double, pi As Double
Dim rotobj As New rotator, txHite As Integer
Dim banner As String
Dim twip As Integer, halftwip As Integer

twip = 1440
halftwip = 720
pi = 3.14159

'get the current page size
pageWidth = ScaleX(GetDeviceCaps(Printer.hdc, HORZSIZE), vbMillimeters, vbInches)
pageHeight = ScaleY(GetDeviceCaps(Printer.hdc, VERTSIZE), vbMillimeters, vbInches)

Debug.Print "Width, Height", pageWidth, pageHeight


txHite = Printer.TextHeight("Tj") 'sample text for calculating height only
Set rotobj.Device = Printer
rotobj.Font = tfont

'do the top/bottom banners
rotobj.Angle = 0 'same for all top & bottom

'tops
Printer.CurrentY = 0 'same for all Top

'top left
Printer.CurrentX = 0
banner = iso.tleft
GoSub handleHorz

'top center
Printer.CurrentX = (pageWidth * halftwip) - (Printer.TextWidth(iso.tcenter) * halftwip)
banner = iso.tcenter
GoSub handleHorz

'top right
Printer.CurrentX = (pageWidth * twip) - Printer.TextWidth(iso.tright)
banner = iso.tright
GoSub handleHorz

' Bottom labels
Printer.CurrentY = ((pageHeight - margs.bottom) * twip)

'bottom left
Printer.CurrentX = 0
banner = iso.bleft
GoSub handleHorz

'bottom center
Printer.CurrentX = (pageWidth * halftwip) - (Printer.TextWidth(iso.bcenter) * halftwip)
banner = iso.bcenter
GoSub handleHorz

'bottom right
Printer.CurrentX = (pageWidth * twip) - Printer.TextWidth(iso.bright)
banner = iso.bright
GoSub handleHorz

'Do the side banners
rotobj.Angle = 90 'same for all (Could make this a param in VueLogic)

'lefts
Printer.CurrentX = 0

'leftbottom
Printer.CurrentY = ((pageHeight - margs.bottom) * twip) - txHite
banner = iso.lbottom
GoSub handleVert

'leftcenter
Printer.CurrentY = (pageHeight * halftwip) + (Printer.TextWidth(iso.lcenter) * halftwip)
banner = iso.lcenter
GoSub handleVert

'lefttop
Printer.CurrentY = (margs.top * twip) + Printer.TextWidth(iso.ltop)
banner = iso.ltop
GoSub handleVert

'rights
Printer.CurrentX = (pageWidth - margs.right) * twip

'rightbottom
Printer.CurrentY = ((pageHeight - margs.bottom) * twip) - txHite
banner = iso.rbottom
GoSub handleVert

'rightcenter
Printer.CurrentY = (pageHeight * halftwip) + (Printer.TextWidth(iso.rcenter) * half)
banner = iso.rcenter
GoSub handleVert

'righttop
Printer.CurrentY = (margs.top * twip) + Printer.TextWidth(iso.rtop)
banner = iso.rtop
GoSub handleVert

'Watermark
Dim aRad As Double

'//complimentary angle
Dim aCompRad As Double

Dim twidth As Long '// changed to long!
Dim xHyp As Double, nHyp As Double

'// need a temp holder to calc hypotenuse, etc.
Dim lCurrY As Long
Dim lCurrX As Long

'rotate watermark diagonally
'work in twips


'// need to work on this...
'find the diagonal hypotenuse
xHyp = Sqr(((pageWidth * twip) ^ 2) + ((pageHeight * twip) ^ 2))
'//

'find the diagonal angle
aRad = Atn(pageHeight / pageWidth)

aCompRad = Atn(pageWidth / pageHeight)

rotobj.Angle = aRad * (180 / pi)

'find the font size for the diagonal
Printer.FontSize = 2

Do
Printer.FontSize = Printer.FontSize + 2

twidth = Printer.TextWidth(iso.wmark)

'// current y changes as text height increases
lCurrY = (pageHeight * twip) - (margs.bottom * twip) - (Cos(aRad) * Printer.TextHeight("Xyj"))

'// Need to recalc the hyp based on text height
'//xhyp = (currenty - top margin) / (cosine(complimentary angle))
If Cos(aRad) < 0.01 Then 'Prevent overflow
xHyp = (pageWidth - margs.left - margs.right) * twip
Else
xHyp = (lCurrY - (margs.top * twip)) / Cos(aCompRad)
End If

'//Debug.Print "HYP = ", xHyp, "twidth = ", twidth, "lcurry = ", lCurrY, "Size = ", Printer.FontSize

Loop Until twidth > xHyp

Debug.Print "printer.ScaleMode", Printer.ScaleMode

Printer.FontSize = Printer.FontSize - 2

'///TEST
'//Printer.FontSize = 64

rotobj.Font = Printer.FontSize & ",Arial,0,0,400,0,0,0,0,3, 2, 1, 34"

Debug.Print rotobj.Font

''''find new hyp length by subtracting the width of the text / 2
''''this sould be the space left over along the diagonal after subtracting the text width
'''nHyp = (xHyp - Printer.TextWidth(iso.wmark)) * 0.5

''''width/height of available area
'''wid = (pageWidth - margs.left - margs.right) * twip
'''hite = (pageHeight - margs.top - margs.bottom) * twip

'''horizontal center should be
'''width of left margin + length of triangle base from hypotenuse
'''Printer.CurrentX = (margs.left * twip) + (nHyp * Cos(aRad))

'//
'//
'// Current x should be 0 + left margin
lCurrX = margs.left * twip
'//

''''vertical center should be
''''page bottom - bottom margin - length of triangle side from hypotenuse - half the text height
''''Printer.CurrentY = (pageHeight * twip) - (margs.bottom * twip) - (nHyp * Sin(aRad)) - (Printer.TextHeight(iso.wmark) * 0.5)

'//
'//
'// Current y should be page height - bottom margin - (cosine(angle) * text height)
lCurrY = (pageHeight * twip) - (margs.bottom * twip) - (Cos(aRad) * Printer.TextHeight("Xyj"))
'///

'// draw a line around what we think the text is
Dim tmpX As Long, tmpY As Long, lTxtH As Long, lTxtW As Long
Printer.CurrentX = lCurrX
Printer.CurrentY = lCurrY
lTxtH = Printer.TextHeight(iso.wmark)
lTxtW = Printer.TextWidth(iso.wmark)
tmpX = lCurrX + (Cos(aRad) * lTxtW)
tmpY = lCurrY - (Sin(aRad) * lTxtW)
Printer.Line -(tmpX, tmpY)
tmpY = Printer.CurrentY
tmpX = Printer.CurrentX
Printer.Line -(tmpX + Sin(aRad) * lTxtH, tmpY + Cos(aRad) * lTxtH)
tmpY = Printer.CurrentY
tmpX = Printer.CurrentX
Printer.Line -(tmpX - (Cos(aRad) * lTxtW), tmpY + (Sin(aRad) * lTxtW))
tmpY = Printer.CurrentY
tmpX = Printer.CurrentX
Printer.Line -(lCurrX, lCurrY)
'//end draw text outline

'// Draw the margins
tmpX = margs.left * twip
tmpY = margs.top * twip
Printer.CurrentX = tmpX
Printer.CurrentY = tmpY
Printer.Line -((pageWidth - margs.right) * twip, tmpY)
tmpX = Printer.CurrentX
tmpY = Printer.CurrentY
Printer.Line -(tmpX, (pageHeight - margs.bottom) * twip)
tmpX = Printer.CurrentX
tmpY = Printer.CurrentY
Printer.Line -(margs.left * twip, tmpY)
tmpX = Printer.CurrentX
tmpY = Printer.CurrentY
Printer.Line -(tmpX, margs.top * twip)
Debug.Print "margs", margs.top, margs.right, margs.bottom, margs.left
'// end drawing margins

'///
Printer.CurrentX = lCurrX
Printer.CurrentY = lCurrY
'//
'//


rotobj.PrintText iso.wmark
Exit Sub

handleHorz:
chunks = Split(banner, vbCrLf)
oldY = Printer.CurrentY
For i = 0 To UBound(chunks)
rotobj.PrintText CStr(chunks(i))
Printer.CurrentY = Printer.CurrentY + txHite
Next i
Printer.CurrentY = oldY
Return

handleVert:
chunks = Split(banner, vbCrLf)
oldX = Printer.CurrentX
For i = 0 To UBound(chunks)
rotobj.PrintText CStr(chunks(i))
Printer.CurrentX = Printer.CurrentX + txHite
Next i
Printer.CurrentX = oldX
Return
End Sub
:huh:

;)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum