Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Converting device independent pixel to device dependent pixel?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-31-2006   #1 (permalink)
fö
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 SpecsSystem Spec
Old 01-31-2006   #2 (permalink)
viliescu
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 SpecsSystem Spec
Old 01-31-2006   #3 (permalink)
fö
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 SpecsSystem Spec
Old 03-01-2006   #4 (permalink)
fö
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 SpecsSystem Spec
Closed Thread

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


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51