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();
} 5 1436
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
what about
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; ?
or
g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit; ?
or
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; ?
"MarkMurphy" <mu****@murphysw.com> wrote in message
news:e0**************************@posting.google.c om... 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(); }
See if you have ClearType turned on; it sometimes causes some unusual
aliasing artifacts.
Display Properties/Appearance/Effects...
Tom Dacon
Dacon Software Consulting
"MarkMurphy" <mu****@murphysw.com> wrote in message
news:e0**************************@posting.google.c om... 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(); }
Thanks all for the suggestions. It turned out in my case that I needed
to use a web-safe color for the background and use one of the text
rendering hint values. Two problems, two solutions. Much
appreciated!
Mark This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Markus Mohr |
last post by:
Hi, everyone,
I have a special problem:
For every monitor resolution in 200 pixel steps from 800 to 1600
pixels I have an image to be shown as centered background-image.
Those images all...
|
by: Konrad Den Ende |
last post by:
I have a function returning a string but the problem is that the
color of it is blue which suits me well for some pages but not for
others. Is it possible to "feel" what the color of the background...
|
by: darkpowrjd |
last post by:
I've been trying to create a new navigation system for my site, and I got everything figured out except for one thing. Here is the CSS code I'm using right now:
body {
font: normal 10px Verdana,...
|
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= |
last post by:
I'm trying to figure out how to modify a panel (panel1) from a
backgroundworker thread. But can't get the panel to show the new controls
added by the backgroundwork task. Here is my code. In...
|
by: jacksoncn |
last post by:
Hey everyone,
I am havin a problem here, maybe someone could lend me their mind for a second. Here it is:
I am using a repeat background on a y axis. When I am testing the file from my...
|
by: LayneMitch |
last post by:
Hello.
After getting great advice on positioning, I've edited my code and it's
looking more stable.
Now I need a little assistance with background image placement.
Please click on this...
|
by: stevedude |
last post by:
CSS newbie again. I have a problem trying to get coffee mug images
within anchor tags to center with my link text for a vertical list
menu. If I use the horizontal/vertical properties of...
|
by: VividWeb |
last post by:
Hi.
I am relatively new to CSS and HTML but have a basic understanding of most things.
One of my backgrounds is not positioning correctly in IE 7 or AOL. The background behind the content...
|
by: thephatp |
last post by:
I'm having a problem with IE rendering correctly. I'm experimenting with using all div's in my pages now, and I'm not very familiar with the quirks of IE.
I have created a sample page, and I'm...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |