1 / 102

Brown Bag Seminar Summer 2007 WPF-Visuals

Brown Bag Seminar Summer 2007 WPF-Visuals. By Kester Marrain. 2D Graphics. Three layers of 2D Graphics: Shapes Drawings Drawing Instructions All 2D operations boils down to: A Geometry A Brush A Pen. Principles of 2D. Composite Rendering - allow elements to paint on top of each other.

jana
Télécharger la présentation

Brown Bag Seminar Summer 2007 WPF-Visuals

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Brown Bag SeminarSummer 2007WPF-Visuals By Kester Marrain

  2. 2D Graphics • Three layers of 2D Graphics: • Shapes • Drawings • Drawing Instructions • All 2D operations boils down to: • A Geometry • A Brush • A Pen

  3. Principles of 2D • Composite Rendering - allow elements to paint on top of each other. • Resolution Independence – uses logical pixels, which equate to 1/96 of an inch. • Pixel Snapping – render with the logical system but when translated to the output device, lines are made to fall exactly on pixels.

  4. Pixel Snapping Illustration

  5. Transforms • Three most common transforms are: • TranslateTransform • ScaleTransform • RotateTransform • Transforms can also be combined.

  6. Geometry • Are the basic building blocks of all 2D graphics in WPF.

  7. Geometry (continued)

  8. Geometry (continued) • Two final geometries are the combining geometries: • CombineGeometry • GeometryGroup

  9. Color • sRGB (standard RGB) – is the native color model for most monitors, and it is the default color model for the Web. • Allows for 3 channels of data, each having 8 bits. • scRGB – is a variable size floating-point encoding for color. • All the encoding support an alpha field.

  10. Color

  11. Brushes • WPF has six brushes: • SolidColorBrush • LinearGradientBrush • RadialGradientBrush • ImageBrush • DrawingBrush • VisualBrush

  12. Gradient Brush

  13. Gradient Brush

  14. Gradient Brush

  15. Gradient Brush

  16. Tiling Brush • ImageBrush, DrawingBrush and VisualBrush are all tiling brushes, they are designed to stretch, or repeat a pattern. • Three operations are used with tiling brushes: • Selecting the content to tile (Viewbox and ViewboxUnits). • Scaling the content (Viewport, ViewportUnits, AlignmentX, and AlignmentY). • Filing the Area with the viewport.

  17. Tiling Brush

  18. Visual Brush • Visual brushes accept any control and uses it as its source.

  19. Pens • Pens are used to outline shapes.

  20. Pens

  21. Pens

  22. Drawings • Drawings are the API for directly talking to the low-level composition engine. • Uses a graph structure which allows a single drawing to appear in multiple places.

  23. Shapes • Shapes bring drawing into the control world.

  24. Shape (continued)

  25. Image • Anything derived from ImageSource in WPF is classified as an Image. • Images have a natural size and metadata associated with it. • WPF has no formal notion of a vector image file format. • However, DrawingImage type offers the ability to use any drawing as an image.

  26. Basic Imaging • Image can be stretched using one of four options: • None: Image is displayed with its natural size. • Fill: The image is scaled to fit entire space. • Uniform: Image made to fit one direction or the other maintaining aspect ratio. • UniformToFill: The image is made to fit the entire space.

  27. Basic Imaging (continued)

  28. Image Metadata • Inclusion of all sorts of information about photographs taken with a digital camera. • Every ImageSource object has a metadata property. • Metadata has two views: • A simplified view of well-known properties • And a query API (GetQuery).

  29. Image Metadata (continued)

  30. Image Metadata (continued)

  31. Image Metadata (continued)

  32. Creating Images • To programmatically generate a raster image, we can use either RenderTargetBitmap or WritableBitmap. • RenderTargetBitmap allows rendering any visible display to a fixed-size raster image.

  33. Creating Images

  34. Saving Images

  35. Opacity • Because opacity composition requires reading of previously rendered display, large portions of an application may be forced into software rendering.

  36. Opacity (continued)

  37. Opacity Mask • Applies opacity to a tree of visuals. • Any brush can be used to apply opacity to a set of visuals.

  38. Opacity Mask (continued)

  39. Opacity Mask (continued)

  40. Opacity Mask (continued)

  41. Bitmap Effects • The ability to perform pixel-by-pixel operations on the output of visuals is usually supported by the BitmapEffect property on UIElement.

  42. Bitmap Effects (continued)

  43. 3D Graphics • Visual3D is the 3D equivalent of Visuals. • Model3D is the equivalent of Drawing. • 3D lacks a control framework. • 3D inherently has four basic concepts: • Models • Materials • Lights • Camera

  44. 3D Graphics (continued) • Models and materials have simple corollaries in the 2D world: Drawings and Brushes. • Geometry3DModel represents a 3D version of a geometry. It is exactly like GeometryDrawing in 2D.

  45. 3D Graphics (continued)

  46. 3D Graphics (continued)

  47. 3D Graphics (continued)

  48. Principles of 3D - Models • All 3D objects eventually are decomposed to a set of triangles. • All texts, shapes, controls, drawings – everything is rendered as 3D triangles. • For all 2D constructs the decomposition is done behind the scenes. • The set of 3D triangles that make up a model is called a mesh. • GeometryModel3D and MeshGeometry3D go hand in hand for creating a model.

  49. Principles of 3D - Models

  50. Principles of 3D – Models (cont)

More Related