image quality problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I've been attempting to draw a simple equilateral
triangle with 10 tick marks on each side. I'm able
to draw one that looks fine on a monitor, but the same
triangle looks lousy when I print it. What am I missing?

Here's the code:

Bitmap bmp = new Bitmap(600, 600);
Graphics g = Graphics.FromImage(bmp);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillRectangle(Brushes.White, 0.0f, 0.0f, 600.0f, 600.0f);
g.TranslateTransform(50.0f, 50.0f);
Pen p = new Pen(Color.Black, 3.0f);
float sideLength = 500.0f;
float cos60 = 0.5f;
float sin60 = (float) Math.Sin(60);
float height = (float) (sin60 * sideLength);
PointF p1 = new PointF(0.0f, 0.0f);
PointF p2 = new PointF((float)(sideLength * 0.5f), height);
PointF p3 = new PointF(sideLength, 0.0f);
g.DrawLine(p, p1, p2);
g.DrawLine(p, p2, p3);
g.DrawLine(p, p3, p1);

float hDivision = sideLength * 0.1f;
float vDivision = height * 0.1f;

float c = 5.0f;
for (float x = hDivision, y = vDivision;
x < sideLength; x += hDivision, y += vDivision) {

PointF top = new PointF(x, -c);
PointF bottom = new PointF(x, c);
g.DrawLine(p, top, bottom);

top = new PointF(0.5f * x - c * sin60, y + c * cos60);
bottom = new PointF(0.5f * x + c * sin60, y - c * cos60);
g.DrawLine(p, top, bottom);

top = new PointF(sideLength - (0.5f * x - c * sin60),
y + c * cos60);
bottom = new PointF(sideLength - (0.5f * x + c * sin60),
y - c * cos60);
g.DrawLine(p, top, bottom);
}

//Yes, I've tried all sorts of image formats...
bmp.Save("Triangle.wmf", System.Drawing.Imaging.ImageFormat.Wmf);
g.Dispose();

Incidentally, I've also tried drawing the lines using RotateTransform,
and the quality was even worse!

ex-neo-con


.



Relevant Pages

  • Re: newbie question
    ... Well your video card cannot do much beyond rasterizing a triangle. ... I have various commands to draw things just like GDI+. ... If you need to draw images, at which point in time you need textures, ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Genealogy question - confirming links
    ... can draw one triangle which shows it isn't true. ... occasion to saying that the only certainly true statement in genealogy ...
    (soc.genealogy.britain)
  • Re: Genealogy question - confirming links
    ... and a biro you can draw one triangle which shows it isn't true. ... Start at any point, draw a quarter of the way round the ball, ... You now have a triangle the angles if which add up ...
    (soc.genealogy.britain)
  • Re: Need some help
    ... teachpack we have to draw a picture and be able to move it if we can. ... my project I need to draw a triangle. ... the problem is to set the color of some squares depending ... You can do this pixel ...
    (comp.lang.scheme)
  • Re: Creating shapes from lines
    ... existing line and then choose fragment will ... When you draw 3 lines to create a triangle it is best if you don't ... If you have draw 3 lines and the second line you draw without releasing ... I edit figure's text then edit box is shown red. ...
    (microsoft.public.visio)