![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Converting device independent pixel to device dependent pixel? Visualizing 100.000 xy-data points with increasing x values by using a Polyline takes a noticeable amount of time - espc. if you have to visualize several data series in one chart control. Any way it's a foolish thing to do so, since the area I am using to plot the data might only be 1000 pixel wide. In the old days of GDI(+) I therefore reduced the number of data points by evaluating which points will be transformed to the same pixel column. But now I do not know anything about the real pixels at all! OK, I could make an estimation and reduce the data as if there were let's say 1000 pixels and this works fine, but isn't there a way to exactly convert a device independent pixel from a canvas to an absolute pixel position on the screen? Thanks, fö |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Converting device independent pixel to device dependent pixel? I don't think there is a way to use device dependent pixels. What you can do is to use the fact that a DIP (device independent pixel) is 1/96 inch so any two points that are too close (for example 1/10th of a pixel - that means 1/960 inch) will be rendered as one. -- Valentin Iliescu [MVP C#] "fö" wrote: > Visualizing 100.000 xy-data points with increasing x values > by using a Polyline takes a noticeable amount of time - espc. > if you have to visualize several data series in one chart control. > Any way it's a foolish thing to do so, since the area I am using > to plot the data might only be 1000 pixel wide. > > In the old days of GDI(+) I therefore reduced the number > of data points by evaluating which points will be transformed > to the same pixel column. > > But now I do not know anything about the real pixels at all! > OK, I could make an estimation and reduce the data as if > there were let's say 1000 pixels and this works fine, but isn't > there a way to exactly convert a device independent pixel from > a canvas to an absolute pixel position on the screen? > > Thanks, > fö |
My System Specs![]() |
| | #3 (permalink) |
| | RE: Converting device independent pixel to device dependent pixel? Finally I found the answer myself: the classes PresentationSource and CompositionTarget help to get a transformation from DIPs to pixel and vice versa. Here's a function that returns the resolution of a canvas' target device in dots per inch: public Point GetResolution(Canvas canvas) { Point dpi = new Point(96, 96); PresentationSource source = PresentationSource.FromVisual(canvas); if (source == null) return dpi; CompositionTarget target = source.CompositionTarget; Matrix m = target.TransformToDevice; MatrixTransform t = new MatrixTransform(m); Point pt1 = new Point(0, 0); pt1 = t.Transform(pt1); Point pt2 = new Point(96, 96); pt2 = t.Transform(pt2); dpi.X = pt2.X - pt1.X; dpi.Y = pt2.Y - pt1.Y; return dpi; } "fö" wrote: > To decide what "too close" exactly means I would need to find out > the current screen resolution and DPI settings. Is there a way to > get these values? > > "viliescu" wrote: > > > I don't think there is a way to use device dependent pixels. > > > > What you can do is to use the fact that a DIP (device independent pixel) is > > 1/96 inch so any two points that are too close (for example 1/10th of a pixel > > - that means 1/960 inch) will be rendered as one. > > -- > > Valentin Iliescu [MVP C#] > > > > > > "fö" wrote: > > > > > Visualizing 100.000 xy-data points with increasing x values > > > by using a Polyline takes a noticeable amount of time - espc. > > > if you have to visualize several data series in one chart control. > > > Any way it's a foolish thing to do so, since the area I am using > > > to plot the data might only be 1000 pixel wide. > > > > > > In the old days of GDI(+) I therefore reduced the number > > > of data points by evaluating which points will be transformed > > > to the same pixel column. > > > > > > But now I do not know anything about the real pixels at all! > > > OK, I could make an estimation and reduce the data as if > > > there were let's say 1000 pixels and this works fine, but isn't > > > there a way to exactly convert a device independent pixel from > > > a canvas to an absolute pixel position on the screen? > > > > > > Thanks, > > > fö |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| scrolling pixel by pixel rather than line by line? | Vista General | |||
| Pixel lines problem | Graphic cards | |||
| help !!! pixel or vertex shaders | Vista Games | |||
| Pixel Shader version & Aero | Vista music pictures video | |||