Re: Background of text is mottled

From: Rutger Smit (DoDotNet_at_gmail.com)
Date: 09/02/04


Date: Fri, 03 Sep 2004 01:41:00 +0200

MarkMurphy wrote:

> Hi,
>
> I'm using the code below to create a background and then write some
> text on it. The area behind the text appears pixelated in the output
> image. I've tried output to jpeg and gif but result is the same.
>
> private void DrawImage()
> {
> string s = "A TEST CAPTION";
> Rectangle frame;
> Font f = new Font("Arial", 10);
> SolidBrush sb;
> Response.ContentType = "image/jpeg";
>
> Bitmap bmp = new Bitmap(200, 24);
> Graphics g = Graphics.FromImage(bmp);
>
> //Draw caption area
> sb = new SolidBrush(Color.Gray);
> frame = new Rectangle(0, 0, 200, 24);
> g.FillRectangle(sb, frame);
>
> f = new Font("Arial", 10);
> sb = new SolidBrush(Color.Black);
> g.DrawString(s, f, sb, 8, 4);
>
> // Send image
> bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
>
> bmp.Dispose();
> g.Dispose();
> sb.Dispose();
> }

Two questions:
1: don't you have to call g.Save(); ?
2: does it get better if you add this line: g.SmoothingMode =
SmoothingMode.HighQuality; ?

Regards,
//Rutger



Relevant Pages

  • Re: What about JPEG, GIF, etc.!!
    ... The patent on GIF expired about two years ago. ... I think GDI+ supports both JPEG and GIF natively. ... Regards, ...
    (microsoft.public.vc.mfc)
  • Re: What about JPEG, GIF, etc.!!
    ... The patent on GIF expired about two years ago. ... I think GDI+ supports both JPEG and GIF natively. ... Regards, ...
    (microsoft.public.vc.language)
  • Re: Save an Image to a file
    ... saving an image to jpeg or gif. ... Best regards, ... a collection of source code, ...
    (comp.lang.java.programmer)

Quantcast