I'm trying to write a peace of code, that takes an inputstream from a fileuploader, resize the image and then drawing some transparent text onto it. The problem is, the text goes grey instead of opaque/transparent and i've got no clue what i'm doing wrong...
I've tried with MakeTransparent and Clear(Color.Transparent), but no luck. Please help me?
Trolderik
Member
645 Points
355 Posts
Transparency/opacity not working
Dec 19, 2011 07:56 AM|LINK
Hi,
I'm trying to write a peace of code, that takes an inputstream from a fileuploader, resize the image and then drawing some transparent text onto it. The problem is, the text goes grey instead of opaque/transparent and i've got no clue what i'm doing wrong... I've tried with MakeTransparent and Clear(Color.Transparent), but no luck. Please help me?
Image img = Image.FromStream(hpf.InputStream); int height = Convert.ToInt32(Math.Round(((double)900 / img.Width) * img.Height)); Bitmap bmp = new Bitmap(900, height); Graphics gr = Graphics.FromImage(bmp); gr.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias; gr.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic; gr.CompositingQuality = Drawing2D.CompositingQuality.HighQuality; gr.DrawImage(img, 0, 0, 900, height); Font font = new Font("Segoe UI", 90); Brush brush = new SolidBrush(Color.FromArgb(96, 255, 255, 255)); gr.DrawString("©", font, brush, new Point(90,90)); bmp.Save(di.FullName + "/" + newfilename, Imaging.ImageFormat.Jpeg); bmp.Dispose(); gr.Dispose(); img.Dispose(); GC.Collect();If this post answered your question or solved your problem, please Mark it as Answer.
vytautas.ziu...
Contributor
3854 Points
691 Posts
Re: Transparency/opacity not working
Dec 19, 2011 08:00 AM|LINK
You can find example here:
http://forums.aurigma.com/yaf_postst159_Writing-SemiTransparent-Text-in-C.aspx
Trolderik
Member
645 Points
355 Posts
Re: Transparency/opacity not working
Dec 19, 2011 08:29 AM|LINK
You don't have an example without external classes?
If this post answered your question or solved your problem, please Mark it as Answer.
vytautas.ziu...
Contributor
3854 Points
691 Posts
Re: Transparency/opacity not working
Dec 19, 2011 08:58 AM|LINK
Sure, there's one:
http://www.dreamincode.net/forums/topic/53101-image-manipulation-with-gdi-in-c%23/
(see the part starting with "Now for writing the semi-transparent watermark").
Trolderik
Member
645 Points
355 Posts
Re: Transparency/opacity not working
Dec 19, 2011 09:14 AM|LINK
When i removed these 2 lines, it worked
If this post answered your question or solved your problem, please Mark it as Answer.