.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Pixel-Perfect 3D Geometry

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :WPF


I have some 3D UserControls in a Viewport3D using Viewport2DVisual3D. Some of them are images that need to be displayed in a pixel-perfect way to prevent blurring.

Is there a way to do this? The mesh geometry is defined in space coordinates and I don't know they relate to pixels: 

<MeshGeometry3D Positions="-1,1,0 -1,-1,0 1,-1,0 1,1,0" TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/>



View Complete Post

More Related Resource Links

WPF Geometry Transformation Tool

The geometry transformer is a simple tool I wrote to scale-, translate- and rotate-transform a geometry in the path mini language.

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

{ End Bracket }: Perfect API Design


Why is good API design so difficult when all you really need is perfection? Intrigued? Read on.

James Waletzky

MSDN Magazine March 2009

Foundations: Bitmaps and Pixel Bits


Charles Petzold takes an inside look at the flexible bitmap pixel formats offered by the retained-mode graphics features of Windows Presentation Foundation.

Charles Petzold

MSDN Magazine June 2008

The Perfect Host: Create And Host Custom Designers With The .NET Framework 2.0


The .NET Framework 2.0 introduces a set of classes that can be used to host designers right out of the box. With the understanding of designers you'll glean from this article, you'll be ready to host them in your own apps.

Dinesh Chandnani

MSDN Magazine March 2006

Geometry Search Question

Hello Group, I am have a column of gemetry type in my sql server 2008 database.  I stored POINT data there IE( POINT(23.989899, 21.090909).  I have a parameter page in which I allow users to put a range on the latitude and longitude. My question is, how can I use those parameters in a where clause to limits the records that come back based upon what the user enters? I have seen examples for most geometric data types but nothing for POINTs.  For example, if the user enters in a latitude of greater than 10.010101 and a longitude of 45.999999, I want to return all the records containing lats > 10.010101 and longs greater 45.999999..... I have tried several solutions with nothing working so far... Any ideas? thanks.  

Text and graphical elements have added/subtracted/shifted pixel

i did something while making a bunch of changes to this application, and now users are reporting shifted/added pixels.  see http://twitpic.com/2k5o9w/full -- notice the white border and image have shifted/added pixels at the top and the text at the bottom also has extra pixels added in. i've tried with and without SnapsToDevicePixels; i don't think that's it? same with RenderingOptions.TextMode. i know it's something i did, though because it did use to be OK (of course). this does NOT happen when we force software rendering, and the machines it's happening on have the latest video drivers (as i understand it, they both have ATI cards, but i'm using an ATI card [a different one] on my laptop and it's fine for me).  it's just a pain because it doesn't happen on all machines, including mine, even though all machines we're trying it on are rendering tier 2. i'm sure it's something stoopid i did, but i can't figure it out. thanks in advance for any suggestions/help! --jon

click event only firing for lower 100 pixel portion of vertical div

 I have a div on the left side of my page. when clicked I toggle a hidden div that flies out to the right. But the click event only works on the bottom portion of the div. The hidden div has a close button div in the lower right. to clicks fine. any ideas? code is below jquery <script type='text/javascript'> $(document).ready(function() { var $scrollingDiv = $("#divReportBanner"); $(window).scroll(function(){ $scrollingDiv .stop() .animate({"top": ($(window).scrollTop()) + "px"}, "fast" ); }); $('.toggle-button').click(function() { $("#divLeftMenuBody").animate({width:'toggle'},400); }); $('#divReportBanner').click(function() { $("#divLeftMenuBody").animate({width:'toggle'},400); }); }); </script> html <div id="divReportBanner" ></div> <div id="divLeftMenuBody" runat="server"> <div style=" overflow: scroll; overflow-x:hidden;width:365px; height:370px;">

Pixel Shader in WPF, are user created shaders run on hardware or in software?

In general, are user made shaders used in WPF, are they run on the video cards hardware? or are they all run in software mode?   I think I read that the default shaders are run in hardware but that user made shaders are not?

System.Windows.Shapes.Ellipse to 'System.Windows.Media.Geometry'



is there a way to use  System.Windows.Shapes.Ellipse or other shapes where  'System.Windows.Media.Geometry' is required?

'No information was found about this pixel format error' on image binding

I've read all the posts I could find on this error but I'm still stumped.

I have a user control with a dependency property named Image.

In the user control I have a stack panel that contains an image and I set the binding in the xaml

<Image HorizontalAlignment="Center" Margin="3,0,0,0" Width="85" Height="75" Source="{Binding ElementName=UserControl, Path=Image}"/>

In a code behind I try to set the image for an instance of this control named WeatherNB

                BitmapImage bi1 = new BitmapImage();
                bi1.UriSource = new Uri(currentImage, UriKind.Relative);
                this.WeatherNB.Image = bi1;

but I get the following error

Unhandled Exception: System.NotSupportedException: No information was found about this pixel format.
   at System.Windows.Media.PixelFormat.CreatePixel

Problem with Pixel Shader 3.0 support in WPF SP1.

I've tried custom effects in WPF with .NET 3.5 SP1. It's amazing feature!
But I tried to compile my pixel shader with ps_3_0 profile and then WPF application throws exception.
So, if I have graphics card with support ps_2_0, ps_3_0 and even ps_4_0, can I use pixel shader profile 3_0 or it's impossible today in WPF? If it's impossible - why? and will WPF dev team provide ps_3_0 support in future releases?

Can Pixel-shader 3.0 based shader effect be used to render to a RenderTargetBitmap?


Hello -

I have written a custom shader effect using PS 3.0 that is working great on screen, however I need to have the ability to create a 'snap shot' of the control and write it out to disk.  I have been attempting to use RenderTargetBitmap, however the shader is not being applied to the rendering.  In another forum on stack overflow I posted a similar question and was told that PS 3.0 does not have a software fall back.  I would like to hear from the MS community if that indeed is the case.  If it is, can someone out there tell me how to capture a control that has been rendered using a PS 3.0 pixel shader.  It would be best if I were able to render the control off screen rather than attempting to capture an image off of the screen.

I wrote a VERY simple program to test the ability to capture PS 3.0 rendering to a RenderTargetBit map.  the code is below:

Hopefully someone out there has a solution!  Unfortunately I can not fall back to PS 2.0...


namespace TestPixelShader
	/// <summary>
	/// Interaction logic for MainWindow.xaml

How to set "Geometry" in GeometryModel3D dynamically


I have a 3D customer control, when it vender, all else are same to each other, only the geometry is different, and it is based on a dependancy property. How to creat the relationship between the geometry in ModelVisual3D and the property. Here is a a part of the codes, which not works:

Customer control name: Test3DCustomerControl

I have a bunch of MeshGeometry3D named "Test3DGeometry", "Test3DGeometry1", "Test3DGeometry2" ...

<Viewport3D ClipToBounds="False" Height="130" Width="70" VerticalAlignment="Top" HorizontalAlignment="Right" >



    <ModelVisual3D x:Name="World">

     <ModelVisual3D x:Name="AmbientLightContainer">


     <ModelVisual3D x:Name="DirectionalLightContainer">

     <ModelVisual3D x:Name="DefaultGroup">


       <GeometryModel3D x:Name="Material"> 


          <EmissiveMaterial Brus

Change bitmap colors and shift it 1 pixel 25 times/sec



I'm struggling with WPF and need some help.

I want declare a bitmap and then change some pixels colors. Then I want to shift the displayed bitmap by one pixel and then change some other pixel colors. This I want to do about 25 times/sec.

I succeeded doing this using winforms which was quite easy (declare bitmap and and use the DrawImage() method to show the two bitmap segments correctly using rect(). I've tried to look for the same functionality in WPF but can't find it. I should be able to  this using winforms in WPF but that doesn't seem right as I'm guessing WPF you be able to support this.


Any hints?




How to find the xy coordinate of an element in a pixel array ?


Lets say that we copy the pixels of an image to an array as follows:


//Copy the pixels to the array
ImgSource.CopyPixels(PixelData, Stride, 0);


Now we have the image as a one dimensional array in PixelData. Is there a way to find out the (x,y) coordinate of each element in this array ?

I need this in order to determine which points in the array are within a specific x,y region.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend