470,602 Members | 1,607 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,602 developers. It's quick & easy.

Datetime stamp on TIFF image

I want to open a TIFF file, put a datetime stamp on it and save that file in
CompressionCCITT4 format back to the same filename.
I have written following code to do this, but getting "Invalid parameter
used. at System.Drawing.Image.Save(String filename, ImageCodeInfo encoder,
EncoderParameters encoderParams)" error.
public void EditTIFFImage(string strImageFile)
{
EncoderParameters encParamsCompress = new EncoderParameters(1);
Encoder encCompress = new Encoder(Encoder.Compression.Guid);
encParamsCompress.Param[0] = new EncoderParameter(encCompress,
(long)EncoderValue.CompressionCCITT4);
Image i = Image.FromFile(strImageFile);
Image t=new Bitmap(i.Width,i.Height);
Graphics g=Graphics.FromImage(t);
g.DrawImage(i,0,0);
i.Dispose();
Font f = new Font("Verdana",30);
g.DrawString(DateTime.Now.ToShortDateString()+":"+ DateTime.Now.ToShortTimeString(),f,Brushes.Black,1 0,10,StringFormat.GenericTypographic);
f.Dispose();
g.Dispose();
t.Save(strImageFile.Replace(".", "temp."), GetEncoderInfo("image/tiff"),
encParamsCompress);
}
private ImageCodecInfo GetEncoderInfo(string mimeType){
ImageCodecInfo[] encoders=ImageCodecInfo.GetImageEncoders();
for (int j=0;j<encoders.Length;j++){
if (encoders[j].MimeType==mimeType)
return encoders[j];
}

throw new Exception( mimeType + " mime type not found in ImageCodecInfo" );
}

Please help.

Best Regards,
Prasad
Nov 17 '05 #1
0 2510

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Robin Becker | last post: by
2 posts views Thread by Al Reid | last post: by
6 posts views Thread by qysbc | last post: by
1 post views Thread by Benny | last post: by
1 post views Thread by Stedak | last post: by
10 posts views Thread by =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= | last post: by
3 posts views Thread by GiJeet | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.