Questions tagged [drawstring]

Graphics.DrawString is a method in the .Net Framework's System.Drawing namespace, by which code can draw text onto an image in .Net code. This is mainly used in ASP.Net, as TextRenderer.DrawText (from System.Windows.Forms) provides more reliable functionality in Windows Forms applications.

313 questions
3
votes
2 answers

Black border around characters when draw Image to a transparent Bitmap

I have to draw a String on a transparent bitmap at first, then draw A to destination canvas. However on certain case, there is black border around the characters. Bitmap* tempImg = new Bitmap(1000, 1000, PixelFormat32bppARGB); Graphics…
user25749
  • 4,825
  • 14
  • 61
  • 83
3
votes
1 answer

how to improve printed text quality after using "graphics.DrawString"?

I have a problem with my text quality after printing ! it's not smooth and antialiases! This is the story : I create a graphic from a bitmap (Graphics.FromImage(MyBitmap)) and I think it's the start point of my problem because I can't use…
Shima.Y
  • 373
  • 4
  • 9
  • 18
3
votes
1 answer

Java Swing Graphics2D drawString slow initiation?

I have encountered a very strange behavior of Java Graphics2D draw String. If I set a font name, such as Font f = new Font("Helvetica", Font.PLAIN, 10); Then on the screen device the first call to g2D.drawString can take as much as 600ms. This…
Gang Su
  • 1,187
  • 10
  • 12
2
votes
0 answers

draw string on CGContext buffer and pick texture data, but the data never changed, why?

In the cocos2d I can not use some method like UIGraphicsGetCurrentContext so i do it like that way following this: memset(textData, 0, sW*sH*4); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context =…
zhen sun
  • 21
  • 1
2
votes
0 answers

When adding text to a metafile, the letter font is changed

I want to add some text to a metafile. The code i use: Metafile m = new Metafile("1.emf"); Graphics grfxVideo = CreateGraphics(); IntPtr ipHdc = grfxVideo.GetHdc(); Metafile mf = new Metafile("2.emf",…
sgkin
  • 113
  • 2
  • 7
2
votes
1 answer

tooltip text erases panel drawing in java

I have a JPanel on which some drawing is performed using paintComponent method and after that when ever a user clicks on the JPanel a string is drawn (or any drawing) on it and as the user moves mouse over the JPanel it shows the coordinates in the…
Harmeet Singh
  • 2,555
  • 18
  • 21
2
votes
1 answer

Draw a String with a specific angle degree in line

I'm drawing a graph with two points of each point having a line with a weight. for example graph: point "15" to point "16" line with the weight of 1.872 and point "16" to point "15" with the weight of 1.567. take a look at my graph for now: I want…
ATB
  • 119
  • 1
  • 9
2
votes
1 answer

Using DecimalFormat (force dot) and drawString() (y seems to be wrong)

Two questions in one, but I have a very short test case demonstrating my problems: import java.awt.*; import java.awt.image.*; import java.io.*; import java.text.*; import java.util.*; import javax.imageio.*; public class Numbers { public…
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
2
votes
1 answer

C# Win7 and Win2019 Convert text to image gives blur, not clear

I have a C# programm, that convert Text to Image by using GDI+ method Graphics.DrawString On my machine with Windows 7 it works good see example image here: But on the Windows Server 2019 it creates blurry, not clear image see example image…
Du10
  • 67
  • 5
2
votes
1 answer

Graphics.DrawString() method throws GDI+ exception when the string length is too long

The below code block which throws System.Runtime.InteropServices.ExternalException: 'A generic error occurred in GDI+. exception when the string passed to draw is too long. public partial class Form1 : Form { string longString; public…
2
votes
1 answer

Graphics.DrawString() & leading padding spaces for Proportional Font

I've been using a monospaced font to render a table onto a graphics object, and to align the columns of text I'd been padding the text using space characters. I've been asked to change the font to a proportional font, and no surprise, but the…
Jon Dewees
  • 2,957
  • 6
  • 31
  • 38
2
votes
3 answers

C# Rotated DrawString from Right Corner

I am trying to draw text on an image from top right corner towards the bottom left corner. My code mess up the positioning of drawstring. so far this code drawing like this but I need help to draw text between these red lines. string img_src =…
aadi1295
  • 982
  • 3
  • 19
  • 47
2
votes
4 answers

How can I draw string in rich format on winform?

I need to write a line of text in rich format on windows form. How can I achive this?
Anton Semenov
  • 6,227
  • 5
  • 41
  • 69
2
votes
2 answers

Drawing a text in the middle of an ellipse

I have an application which at some point draws many circles on a Panel control. Then I want to name each circle (just a letter and a number). And I want the text to be centered, to make it look nice. For now, I have something like this: What I do,…
minecraftplayer1234
  • 2,127
  • 4
  • 27
  • 57
2
votes
0 answers

Drawstring custom font working in a TextBox control but not working in a Form Paint event

I created a simple WinForm Form and tested a custom font file. Basically I just add several chinese characters (which do not exist) to a existing font file. Strange thing is that the font only works in WinForm controls such as TextBox, Grid..etc.…