Hey folks,
I have tested the following program with a small tif size (say less than 500 KB). But, if it is more than 5 MB, the system is taking much time to load the image. Please note that the problem is happening only if i am using TIF image, which is having size more than 500 kb.
I would like to know any alternate method to add an overlay text to a multipage/TIFF image without concerning size or any LZW compression technique.
The following are sample procedure:
Eg for testing :
AddTextOnImage("c:\temp\test.tif","Sample Text")
Imports
System.DrawingImports
System.Drawing.ImageImports
System.Drawing.ImagingImports System.Drawing.Drawing2D
Private Sub AddTextOnImage(ByVal FileName As String, ByVal OverlayText As String, ByVal FontName As Font, Optional ByVal FormatType As String = "image/tiff")
Try
' Get the codec for tiff files Dim getCodecInfo As ImageCodecInfo = NothingDim ice As ImageCodecInfo
For Each ice In ImageCodecInfo.GetImageEncoders
If ice.MimeType = FormatType Then
getCodecInfo = ice
Exit For End If Next ice 'Use the save encoder Dim enc As Encoder = Encoder.SaveFlag Dim ep As New EncoderParameters(1)ep.Param(0) =
New EncoderParameter(enc, CLng(EncoderValue.MultiFrame)) Dim tifPages As Bitmap = Nothing' Getting the original image frame
tifPages =
CType(Image.FromFile(FileName), Bitmap) Dim outputImage As Bitmap = New Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb) Dim g As Graphics = Graphics.FromImage(outputImage)g.CompositingMode = CompositingMode.SourceCopy
g.InterpolationMode = InterpolationMode.HighQualityBicubic
Dim destRect As Rectangle = New Rectangle(0, 0, tifPages.Width, tifPages.Height) Dim sf As StringFormat = CType(StringFormat.GenericTypographic.Clone(), StringFormat)sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
g.DrawImage(tifPages, destRect, 0, 0, tifPages.Width, tifPages.Height, GraphicsUnit.Pixel)
g.DrawString(OverlayText,
New Font("Arial", 48, GraphicsUnit.Point), Brushes.Red, New RectangleF(0, 0, 40, 40), sf)g.Dispose()
outputImage.Save(
"c:\temp\output.tif")
Catch ex As Exception
Beep()
MsgBox(ex.Message)
End Try
End SubI would appreciate any further suggestions
thanks - Binoy

Images - including TIFF multiframe/Image - Overlay images with text...Sample programs enclosed. Suggestions welcome.