Re: Two newbie questions



If you're printing then a real-world measurement system such as points,
millimeters or inches is best.

Remember that the printer bounds are declared in 100ths of an inch. NOT
pixels. You need to multiply the printer bounds by the DPI to get the real
pixel count if you want to use pixels at-all.

I haven't the faintest idea what sort of values you're producing with your
calculations on how the reciprocal width of a picturebox has a relation to
the left edge of a textbox. This is more esoteric than quantum physics. The
text doesn't show up because the result of that calculation puts it outside
the page margins obviously.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"zhaounknown" <zhaounknown@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7A138DA2-2217-4C11-8BDC-C1B879506E08@xxxxxxxxxxxxxxxx
> 1. PaintEventArgs.Graphics.Drawstring() need to specify the upper-left
> coordinate for the text to be drawn. What measure unit should be used for
> the
> coordinate?
>
> 2. Why the following piece of code can't print the Texts (on letter
> paper)?
> However, if remove the "e.Graphics.PageUnit=GraphicsUnit.Inch;" and set
> 0.5F/0.6F to be 0.5*100 and 0.6*100 can work.
>
> private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
> {
> Font newFont= new System.Drawing.Font("Arial", 10F,
> System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
> ((System.Byte)(134)));
>
> e.Graphics.PageUnit=GraphicsUnit.Inch;//
> float
> leftInch=(float)(this.textBox1.Left*1.0/this.pictureBox1.Image.Width*8.5);
> float
> topInch=(float)(this.textBox1.Top*1.0/this.pictureBox1.Image.Height*11.0);
>
> e.Graphics.DrawString(this.textBox1.Text, this.textBox1.Font,
> Brushes.Black,
> leftInch, topInch);
>
> e.Graphics.DrawString("X", newFont, Brushes.Black, 0.5F, 0.6F);
> }


.



Relevant Pages

  • Re: Extract partial image from larger image, performance question
    ... This means decoding the LZW compression in the first instance. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... However when I call the LockBits method on the loaded image (so I can copy ... the needed pixels into the smaller image) it takes about 8 seconds. ...
    (microsoft.public.dotnet.framework.drawing)
  • How to convert image from Format1bppIndexed to Format24bppRgb?
    ... 10000x10000 pixels are fine when I make calls to FromImage, DrawImage, ... Find great Windows Forms articles in Windows Forms Tips and Tricks ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: DrawImage and NearestNeighbor bug?
    ... > Find great Windows Forms articles in Windows Forms Tips and Tricks ... >> I am drawing an image, stretched, with interpolation set to ... >> I created a checkboard of 5x5 pixels and painted it in a panel. ... >> rounding error in the interpolation code to me, but maybe it's by design? ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: brightness vb.net images
    ... such an image is due to dithering of pixels. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ...
    (microsoft.public.dotnet.framework.drawing)

Loading