473,224 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

.NET Bitmap's Graphics.DrawString() // HDC ExtTExtout issues

In my .NET application I have some text rendered through GDI.
It draws and print nicely.

Now I would like to implement image export.
So I create a
new System.Drawing.Bitmap(width, height)
then I create a Graphic g = Graphics.FromImage(bmp)
then I use
HDC hdc = g.GetHdc();
and use ExtTextOut ....

problem is the output is horrible!
in fact even g.DrawString() has an horrible output.. (ultra heavy/bold
characters, so much so that's almost unreadable...)

With the HDC if I CreateFont(......, ANTIALIASED_QUALITY, ...) I have
something which is better but on the screen I better use CreateFont(......,
CLEARTYPE_QUALITY, ...)

How come output on the Bitmap is so bad?
Any tips?
May 27 '06 #1
2 4500
Hi,

You can use the following GDI+ methods to improve the output:

Graphics::SetInterpolationMode

Graphics::SetSmoothingMode

Graphics::SetPixelOffsetMode

http://msdn.microsoft.com/library/de...lationMode.asp

http://msdn.microsoft.com/library/de...othingmode.asp

http://msdn.microsoft.com/library/de...OffsetMode.asp

http://msdn.microsoft.com/library/de...us/gdiplus.asp

http://msdn.microsoft.com/library/de...ce/flatapi.asp

Hope these suggestions helps,

Kellie.

May 27 '06 #2
"Lloyd Dupont" <net.galador@ld> wrote in message
news:uf**************@TK2MSFTNGP02.phx.gbl...
In my .NET application I have some text rendered through GDI.
It draws and print nicely.

Now I would like to implement image export.
So I create a
new System.Drawing.Bitmap(width, height)
then I create a Graphic g = Graphics.FromImage(bmp)
then I use
HDC hdc = g.GetHdc();
and use ExtTextOut ....

problem is the output is horrible!
in fact even g.DrawString() has an horrible output.. (ultra heavy/bold
characters, so much so that's almost unreadable...)

With the HDC if I CreateFont(......, ANTIALIASED_QUALITY, ...) I have
something which is better but on the screen I better use
CreateFont(......, CLEARTYPE_QUALITY, ...)
I suspect your image export is losing the alpha channel, so all your
partially transparent pixels on the edges of the text are becoming solid.

You might try filling in the image with an opaque background first so you
get blending and no transparency.

How come output on the Bitmap is so bad?
Any tips?

May 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: charsh | last post by:
Hi, I using the code below to draw a text in a pictureBox1. //Start--------------------------------------------------------------- private void button1_Click(object sender, System.EventArgs e)...
2
by: Frecklefoot | last post by:
I have a Bitmap image on which I want to render a string. I know about the GDI+ DrawString() method, but I need a Graphics reference to use it. I couldn't find any function to get the Bitmap's...
8
by: active | last post by:
How can I increase the size of a bitmap while preserving the image in it. I tried (among many other things) : b1 = New Drawing.Bitmap(b1, picData.Width, picData.Height) and it doesn't seem...
8
by: nobody | last post by:
How do I save a PictureBox bitmap with changes drawn on the bitmap? This doesn't do it: PictureBox1.Image.Save("key30.bmp")
5
by: Charles A. Lackman | last post by:
Hello, I have created a complete PrintDocument and need to create an image from it. How is this done? e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality...
0
by: benfly08 | last post by:
Hi, guys. I have a program to draw bar/pie chart based on the data i hard coded in it. However, my image comes with "BLACK" background color. I don't know how to fix this. The code snippet is...
9
by: poifull | last post by:
Hi All, I have the following task: 1. create an image object in memory (a rectangle with nothing on it) 2. write some text on the rectangle 3. rotate the image 90 degree 4. save the image to a...
5
by: almurph | last post by:
RE: Tryign to convert Graphics object to a bitmap Hi, Hope you can help me with this. I have to open a file and add some text to it and then display it. So I create an Image object then...
2
by: Jeff | last post by:
hey asp.net 2.0 Below you see my code. #1 How to place the text at the buttom right of the image? I mean how do I calculate the x,y parameter of the DrawString method?
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.