473,461 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

.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 4518
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
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.