Windows Develop Bookmark and Share   
 index > Windows Forms General > pixel relative to milimiter
 

pixel relative to milimiter

Hi
I have a jpeg image and need to scale it so it will fit in an area of 10 x 7 mm when printing. 

I would like do something like this.

get width and height of image in pixels
if image is to high to fit in 10 mm printing 
  scale it to fit 10 mm height
if image is to wide to fit in 7 mm printing
  scale it to fit 7 mm width

is it possible to do this? have search all the web for a soloution converting pixels to millimeter without any luck. My last hope lies with you guys and I would be forever grateful for any help.

/martin
MigrationUser 1  Tuesday, April 06, 2004 3:46 AM
This won't be easy to do though the math is simple and implemented in the Matrix class.
all factors come in like screenresolution etc.
the Graphics where your picture resides (at least my pictures do) has a Matrix called Transform which does the final transformation for your picture, you can tweak a Matrix scaling thus that its fits your pixel to mm conversion and tranform the points you need to convert through this matrix and set your Graphics variables Transform (which seems to be set/read-only) to this Matrix to show your picture.
But note: the matrix will (I think) be different on systems which uses other resolution.

Hope this non-solution helps, though mm and pixel seem members of the same enumeration the .Net framework doesn't seem to have converters between them. I don't know whether it is possible for the PTB's to factor in all the factors that come in into this conversion.
MigrationUser 1  Wednesday, April 07, 2004 1:46 AM

You can use google to search for other answers

Custom Search

More Threads

• Graphics.DrawLines tends to give erraneous results sometimes but only when using Pen with DashStyle set to Solid
• .NET Dynamic Web Forms Advice Needed
• TextbBox size in GridView Edit mode
• Examples of capturing windows messages from external programs.
• FormClosing-event doesn't fire if owner form is modal
• Wrong key after deletion
• Using variables in uninstantiated classes
• Flashing Cell
• Textbox in ContextMenuStrip
• Finding modified columns of the modified rows