TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ganeshamoorthy A
NA
24
8.8k
watermarking in Tiff
Jul 4 2019 4:27 AM
i am tring add a watermark on my file. but i am getting error 'A Graphics object cannot be created from an image that has an indexed pixel format'
Here is my code . please give a solution for this
string text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
string fileName = @"C: \Users\ENGAPP73\Desktop\t4.tiff";
string watermarkText = "2914 View: " + text;
Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
using (Graphics grp = Graphics.FromImage(image))
{
Brush brush = new SolidBrush(Color.Red);
Font font = new Font("Arial", 30.0f, FontStyle.Bold, GraphicsUnit.Pixel);
SizeF textSize = grp.MeasureString(watermarkText, font);
Point position = new Point((image.Width - ((int)textSize.Width + 10)), (image.Height - ((int)textSize.Height + 10)));
grp.DrawString(watermarkText, font, brush, position);
stream.Dispose();
File.Delete(fileName);
image.Save(fileName);
Reply
Answers (
1
)
Cloud Migration
How to Upload and download multiple files asynchronously