![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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) |
| Guest | 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) |
| Guest | RE: Converting device independent pixel to device dependent pixel? 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![]() |
| | #4 (permalink) |
| Guest | 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 | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| changing pixel size on pictures | Jeni | Vista music pictures video | 2 | 05-16-2008 10:48 PM |
| help !!! pixel or vertex shaders | rj runyan | Vista Games | 1 | 11-02-2007 12:08 PM |
| Jpeg Image Pixel Banding | Tim Murphy | Vista music pictures video | 0 | 10-31-2007 02:34 PM |
| Pixel Shader version & Aero | Mark B | Vista music pictures video | 2 | 10-25-2006 05:57 PM |