|
|
|
| The image of a form | The annotated image |
Victor Library for 32-bit Windows holds an image in memory and by calling the addtext function you can easily specify a text string, color, position, and size to add. More more control over the text, use the addtextex function.
To save the image, call one of the Victor savefile functions in the Victor Library.
In this function we add text to the current image being processed as defined by the vicnet1 application's global image descriptor, vimage. Requires Victor Image Processing Library for 32-bit Windows v 6.0 or higher.
Private Sub Addtext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Addtext.Click
' text | add text
Dim rcode As Integer
Dim text As String
Dim textheight As Integer
Dim color As Integer
' Add text to the global vimage
text = "Your name here"
textheight = 20 ' 20 pt
color = 0 ' Black
vimage.stx = 10 ' Position for text (10, 20)
vimage.sty = 20
' Write the text into the image area for the annotation
rcode = addtext(color, textheight, "Courier New", text, vimage)
vimage.stx = 0 ' Restore position to (0,0) for future operations
vimage.sty = 0
VicimagetoPicturebox(vimage, PictureBox1)
PictureBox1.Refresh()
End Sub
Public Function annotateimage() As Long
Dim rcode As Long
Dim resimg As imgdes
Dim text As String
Dim textheight As Integer
Dim color As Integer
Dim filedata As TiffData
Dim filename As String
filename = "test.tif"
rcode = tiffinfo(filename, filedata)
If (rcode = NO_ERROR) Then
rcode = allocimage(resimg, filedata.width, filedata.length, filedata.vbitcount)
If (rcode = NO_ERROR)
Then rcode = loadtif(filename, resimg)
If (rcode <> NO_ERROR) Then
GoTo bottom
End If
End If
End If
' Successfully loaded the tiff image, ready to add text to it
text = "Your name here"
resimg.stx = 10 ' Position for text (10, 20)
resimg.sty = 20
' Write the text into the image area for the annotation
rcode = addtext(color, textheight, "Courier New", text, vimage)
resimg.stx = 0 ' Restore position to (0,0) for future operations
resimg.sty = 0
rcode = savetif("testover.tif", resimg, 0)
freeimage resimg
bottom:
annotateimage = rcode
End Function
int annotate(imgdes *resimg, char far *text)
{
int rcode = NO_ERROR;
int textheight;
int color;
// Add text to the global vimage
textheight = 20; ' 20 pt
color = 0; ' Black
resimg->stx = 10; ' Position for text (10, 20)
resimg->sty = 20;
' Write the text into the image area for the annotation
rcode = addtext(color, textheight, "Courier New", text, vimage);
resimg->stx = 0; ' Restore position to (0,0) for future operations
resimg->sty = 0;
return(rcode);
}
Victor Image Processing Library homepage | Victor Product Summary | more source code