| | |
drawing methode in C#
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2009
Posts: 972
Reputation:
Solved Threads: 212
•
•
•
•
Don't know what "print them in CM " is. Take into account that dpi(dots per inch) on the screen almost always differs from the dpi on a printer.
. If you can get ahold of your printer graphics or create an image you will find a
.VerticalResolution and .HorizontalResolution that will give you the pixels per inch as danny indicated. Do the math and draw your shapes to the size you want and send them to the printer with no scaling and the print driver should print your image as the correct size. Welcome my friend to the most complicated question you may have ever asked. but I am here to show you the way!
First off, all drawing in GDI+ is done based on pixels... now that means nothing to a printer, because of a little concept called pixel density! better known as dots per inch, or! DPI!!!
now DPI varies from display to display. and according to printer settings! so in theory, if your printer was set up to directly print whatever you sent to it... and you drew a 300 px line, and printed it at a 300 DPI you would then have a 1 inch long line!
but wait!!! that means every picture you printed off the web would look like a postage stamp! YUK!!!
that's because we forgot about resolution... now the resolution of an image is how many Pixels there are in any given unit of measurement.
standard web resolution is 72 pixels per inch. so if your line is 300 px wide, and the printer is set to a DPI of 300 the actual print size on paper would be approximately 4.2 inches!
now to keep things looking consistent printer drivers scale images based on their resolution and DPI, so images of the same pixel size always come out the same size on paper, they just look better with more dots. so ignore the target printer DPI settings in your battle to create print graphics.
you need to focus on the resolution of the images you create!
back to our 300px line example, with a resolution of 72 pxperinch, we got a 4.2 inch line on paper... well if the image resolution were 144 we would get a better quality image, but it would be the same size on screen, but half the size in print! so our 300px image, which look the same size on screen, then prints to 2 inches!
So, if you are only concerned with being able to print an image to an exact size, all you need to be concerned with is the resolution of the image you are printing.
Now here comes the trick, as far as .net 3.5 is concerned. any image type that inherits from "Image" is going to be have a resolution of 96 Pixles/Inch. regardless of the the original resolution of the image. if you create a new bitmap, its 96 Pixles/Inch.
(this could be a system independent piece of information, but all the research I have done concludes to this. to be sure, just use the Image, or Bitmap.HorizontalResolution property in your conversions. it for me and my colleges has always returned 96)
this means if you create a new bitmap image of 300px, and draw a line across all 300px of it, and print it out without scaling it. you will have a measurable print of 3.125 Inches or almost 8 CM.
so you simply divide pixels by resolution to get actual print size.
since .net bitmaps are always 96Px/In (for some unknown reason)
Pixles/resolution = print size.
300px / 96 px/In = 3.125in printsize
or since there are 2.54 CM in an In.
300px / 37.796 px/CM = 7.937CM printsize
i hope this clears up your troubles!
First off, all drawing in GDI+ is done based on pixels... now that means nothing to a printer, because of a little concept called pixel density! better known as dots per inch, or! DPI!!!
now DPI varies from display to display. and according to printer settings! so in theory, if your printer was set up to directly print whatever you sent to it... and you drew a 300 px line, and printed it at a 300 DPI you would then have a 1 inch long line!
but wait!!! that means every picture you printed off the web would look like a postage stamp! YUK!!!
that's because we forgot about resolution... now the resolution of an image is how many Pixels there are in any given unit of measurement.
standard web resolution is 72 pixels per inch. so if your line is 300 px wide, and the printer is set to a DPI of 300 the actual print size on paper would be approximately 4.2 inches!
now to keep things looking consistent printer drivers scale images based on their resolution and DPI, so images of the same pixel size always come out the same size on paper, they just look better with more dots. so ignore the target printer DPI settings in your battle to create print graphics.
you need to focus on the resolution of the images you create!
back to our 300px line example, with a resolution of 72 pxperinch, we got a 4.2 inch line on paper... well if the image resolution were 144 we would get a better quality image, but it would be the same size on screen, but half the size in print! so our 300px image, which look the same size on screen, then prints to 2 inches!
So, if you are only concerned with being able to print an image to an exact size, all you need to be concerned with is the resolution of the image you are printing.
Now here comes the trick, as far as .net 3.5 is concerned. any image type that inherits from "Image" is going to be have a resolution of 96 Pixles/Inch. regardless of the the original resolution of the image. if you create a new bitmap, its 96 Pixles/Inch.
(this could be a system independent piece of information, but all the research I have done concludes to this. to be sure, just use the Image, or Bitmap.HorizontalResolution property in your conversions. it for me and my colleges has always returned 96)
this means if you create a new bitmap image of 300px, and draw a line across all 300px of it, and print it out without scaling it. you will have a measurable print of 3.125 Inches or almost 8 CM.
so you simply divide pixels by resolution to get actual print size.
since .net bitmaps are always 96Px/In (for some unknown reason)
Pixles/resolution = print size.
300px / 96 px/In = 3.125in printsize
or since there are 2.54 CM in an In.
300px / 37.796 px/CM = 7.937CM printsize
i hope this clears up your troubles!
Last edited by Diamonddrake; Sep 16th, 2009 at 8:43 pm.
Oh yes! I forgot to answer the "official" question about diagonal lines! lol
ok here's the dig, pixels don't have to be square! they can be rectangular!
but as far as images in .net 3.5 are concerned, there are only square pixles. (even if you have a funny screen resolution and the pixels are stretched, they are still offically square in a .net Image)
to test this just check the horizontalResolution and VerticalResolution of the image, you of course will get 96 for both, showing you that the pixels are square. This means, using our rule, that a line 300 px long drawn on a new bitmap will always be 3.125 in long on paper, REGARDLESS of what direction it goes, be it vertical, horizontal, diagonal, 10 degrees or 70 degrees!
Best of luck!
ok here's the dig, pixels don't have to be square! they can be rectangular!
but as far as images in .net 3.5 are concerned, there are only square pixles. (even if you have a funny screen resolution and the pixels are stretched, they are still offically square in a .net Image)
to test this just check the horizontalResolution and VerticalResolution of the image, you of course will get 96 for both, showing you that the pixels are square. This means, using our rule, that a line 300 px long drawn on a new bitmap will always be 3.125 in long on paper, REGARDLESS of what direction it goes, be it vertical, horizontal, diagonal, 10 degrees or 70 degrees!
Best of luck!
•
•
Join Date: Apr 2009
Posts: 6
Reputation:
Solved Threads: 0
thanks everybody
I read all of your note
I think that you want to say is true that I saw the diagonal lines longer than horizental in screen but I can print them and then see them equal if I calcluate my measures like your note!!
I will do this and...
I read all of your note
I think that you want to say is true that I saw the diagonal lines longer than horizental in screen but I can print them and then see them equal if I calcluate my measures like your note!!
I will do this and...
Last edited by z_zendegi; Sep 17th, 2009 at 3:41 pm.
![]() |
Similar Threads
- Angry Photoshop CS wont accept my drawing pad (Windows Software)
- AutoShapes/Drawing toolbar makes Word freeze up (Mac Software)
- drawing - stickman with array (C++)
- Drawing lines by click two points (Java)
- Word 2002 hogs CPU with Visio drawing embedded. (Windows NT / 2000 / XP)
Other Threads in the C# Forum
- Previous Thread: Form.Enabled taking over .8 seconds
- Next Thread: Generics Real world example
Views: 928 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for drawing







