TransparentCopy
The TransparentCopy performs a transfer of the data corresponding to a rectangle of pixels from the active image into a inactive image applying
transparency and semi-transparency.
TransparentCopy
varDx, varDy, varWidth, varHeight, varSX, varSY, vColor1[, vTransp1][, vTranspOthers]
Parameters
-
varDx
-
Specifies the logical x-coordinate of the upper-left corner of the destination rectangle.
-
varDy
-
Specifies the logical y-coordinate of the upper-left corner of the destination rectangle.
-
varWidth
-
Specifies the logical width of the source and destination rectangles.
-
varHeight
-
Specifies the logical height of the source and destination rectangles.
-
varSX
-
Specifies the logical x-coordinate of the upper-left corner of the source rectangle.
-
varSY
-
Specifies the logical y-coordinate of the upper-left corner of the source rectangle.
-
vColor1
-
Specifies the color to apply transparency information. You can use either color number eariler defined by SetColor
function call or array from 3 elements containing the RGB value of color (you can use, for example, the Array function of VB script as well as Dim declaration).
-
vTransp1
-
Optional. Specifies the transparency value for pixels having vColor1 color. That value should be in the range from
0 (the color is absolutely transparent) to 100 (the color is opaque). The default value is 0.
-
vTranspOthers
-
Optional. Specifies the transparency value for pixels not having vColor1 color. That value should be in the range from
0 (the color is absolutely transparent) to 100 (the color is opaque). The default value is 100.
Remarks
The "active image" means the image currently selected by
SelectClipboard calling.
The TransparentCopy method allows to set the transparency value for pixels having some color and for other pixels independently.
Example
The following example places the watermarking text on image. The image are read into primary imagespace, and the watermark image
with text is createed in the secondary imagespace. It is not necessary to make the size of secondary imagespace the same as original image size:
for example, the size of secondary imagespace can be less to contains only the picture to place over image.
View result
file_name="c:\images\mount.jpg"
text_string="WATERMARK"
Set g=CreateObject("shotgraph.image")
Main()
Sub Main()
t=g.GetFileDimensions(file_name,xsize,ysize)
if xsize<=0 or ysize<=0 then Exit Sub
g.CreateImage xsize,ysize,4
' Gray color for transparent backgroung
g.SetColor 0,100,100,100
' White color for text
g.SetColor 1,255,255,255
' Black color for shadow
g.SetColor 2,0,0,0
' Reading the image into primary imagespace
g.ReadImage file_name,pal,0,0
' Creating the secondary image space for watermark image
g.InitClipboard xsize,ysize
g.SelectClipboard True
' Drawing on the secondary imagespace
g.SetBgColor 0
g.FillRect 0,0,xsize-1,ysize-1
g.CreateFont "Times New Roman",0,48,0,True,False,False,False
g.SetBkMode "TRANSPARENT"
' Place the text in the center of the image
g.SetTextAlign "TA_CENTER","TA_BASELINE"
xtext=xsize\2
ytext=ysize\2
g.SetDrawColor 1
g.SetTextColor 2
' Uncomment these lines to add shadows
'g.TextOut xtext-2,ytext-2,text_string
'g.TextOut xtext+2,ytext+2,text_string
g.SetTextColor 1
g.TextOut xtext,ytext,text_string
g.TransparentCopy 0,0,xsize,ysize,0,0,0,0,15
g.SelectClipboard False
g.JpegImage 90,0,"c:\images\new\wmark_mount.jpg"
End Sub