watermark - C# watermarking not working for .gif and .tif images -
i'm trying watermark images .png image .jpg , .png images getting watermarked .tif , .gif images give error.
i'm doing in c#. , errror :
{"a graphics object cannot created image has indexed pixel format. @ system.drawing.graphics.fromimage(image image) @ watermarking.test_image_watermak.button1_click(object sender, eventargs e) "}
my code
filestream fs = new filestream(img, filemode.open, fileaccess.read); image = image.fromstream(fs); int newwaterwidth = (int)((float)image.width * .30); int newwaterheight = (newwaterwidth * watermarkimage.height) / watermarkimage.width; bitmap resizedwaterm = new bitmap(newwaterwidth, newwaterheight); graphics g = graphics.fromimage((image)resizedwaterm); g.drawimage(watermarkimage, 0, 0, newwaterwidth, newwaterheight); ***graphics imagegraphics = graphics.fromimage(image);*** //error @ line texturebrush watermarkbrush = new texturebrush((image)resizedwaterm); int x = (image.width / 2 - resizedwaterm.width / 2); int y = (image.height / 2 - resizedwaterm.height / 2); watermarkbrush.translatetransform(x, y); imagegraphics.fillrectangle(watermarkbrush, new rectangle(new point(x, y), new size(resizedwaterm.width + 1, resizedwaterm.height))); var filename = path.getfilename(img); image.save(outputfolder + "\\" + filename);
is there different need these types of images ???
"a graphics object cannot created image has indexed pixel format." tells itself. gif images palette-based, tiff image seems indexed (while there full-color tiffs).
Comments
Post a Comment