I want to khow about drawing methode in C# that has no dependence in pixel, do anyone can help me?
I want to draw patterns and then print them, I can Draw them but when I want to print, I have Problems with measurments because I draw them pixel by pixel and now I want to print them in CM
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.
I think he/she is referring to centimeters, but I suppose it could mean color monitor. AcronymFinder.com didn't have either of those for CM in InfoTech related definitions (26 possibilities), so I wanted to see what someone else would say--;).
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.
I found my .VerticalResolution and .HorizontalResolution,convert pixels to Cm and draw lines. it works good for horizental and vertical lines but when I want to draw diagonal Lines I have problem, this is the reason that I want to khow about drawing method that has no dependence in pixel.
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.
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!
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 Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...