|
| 1 | +## Introduction |
| 2 | + |
| 3 | +SVG (Scalable Vector Graphic) is an XML based graphic format. |
| 4 | + |
| 5 | +This little project started out as a simple `SVG` to `XAML` converter. I looked at some simple SVG files and noticed |
| 6 | +the similarity to `XAML` defined graphic, and decided to write a converter. However, I soon realized that SVG is a |
| 7 | +very complex format, and at the same time, I found no good reason for converting to `XAML` just to show the image |
| 8 | +on the screen, so instead, I started working on the `SVG`, `SVGRender` and the `SVGImage` classes. |
| 9 | + |
| 10 | +* The `SVG` class is the class that reads and parses the XML file. |
| 11 | +* `SVGRender` is the class that creates the WPF Drawing object based on the information from the SVG class. |
| 12 | +* `SVGImage` is the image control. The image control can either |
| 13 | + - load the image from a filename `SetImage(filename)` |
| 14 | + - or by setting the Drawing object through `SetImage(Drawing)`, |
| 15 | + which allows multiple controls to share the same drawing instance. |
| 16 | + |
| 17 | +The control only has a couple of properties, `SizeType` and `ImageSource`. |
| 18 | + |
| 19 | +* `SizeType` - controls how the image is stretched to fill the control |
| 20 | + - `None`: The image is not scaled. The image location is translated so the top left corner of the image bounding box is moved to the top left corner of the image control. |
| 21 | + - `ContentToSizeNoStretch`: The image is scaled to fit the control without any stretching. Either X or Y direction will be scaled to fill the entire width or height. |
| 22 | + - `ContentToSizeStretch`: The image will be stretched to fill the entire width and height. |
| 23 | + - `SizeToContent`: The control will be resized to fit the un-scaled image. If the image is larger than the max size for the control, the control is set to max size and the image is scaled. |
| 24 | + - `ViewBoxToSizeNoStretch`: Not the content of the image but its viewbox is scaled to fit the control without any stretching.Either `X` or `Y` direction will be scaled to fill the entire width or height. |
| 25 | + |
| 26 | +For `None` and `ContentToSizeNoStretch`, the Horizontal/VerticalContentAlignment properties can be used to position the image within the control. |
| 27 | + |
| 28 | +* `ImageSource` - This property is the same as `SetImage(drawing)`, and is exposed to allow for the source to be set through binding. |
0 commit comments