wpf - DrawingImage icon gets automatically trimmed when stretch=uniform -


we use vector icons exported expression design in our application, noticed empty space in icons gets trimmed away when displayed inside stretched image. since whole point of having vector icons allow them stretch , scale nicely, seems strange.

here example. both red , blue star designed in 32 pixels wide document, blue star smaller. setting stretch property uniform makes 2 icons same size.

enter image description here

is possible solve , keep whitespace around icons? guess possible workaround add transparent background rectangle covers whole icon area, seems bad solution me.

<window     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     x:class="generaltest.mainwindow"     x:name="window"     title="mainwindow"     width="640" height="480">      <window.resources>         <drawingimage x:key="small_blue_star">             <drawingimage.drawing>                 <drawinggroup>                     <drawinggroup.children>                         <geometrydrawing brush="blue" geometry="f1 m 20.4989,22c 20.4634,22.0177 16.2771,19.0022 16.2416,19.0022c 16.2061,19.0022 12.0021,22.0177 11.9844,22c 11.9489,21.9823 13.4921,17.0332 13.4744,16.9977c 13.4744,16.9623 9.4655,14.0354 9.48323,13.9999c 9.48323,13.9644 14.45,14.0177 14.4855,13.9999c 14.5032,13.9822 16.2061,8.99765 16.2416,8.99765c 16.2771,8.99765 17.9623,13.9822 17.98,13.9999c 18.0155,14.0177 22.9823,13.9644 23,13.9999c 23,14.0354 18.9911,16.9623 18.9911,16.9977c 18.9734,17.0332 20.5166,21.9823 20.4989,22 z "/>                     </drawinggroup.children>                 </drawinggroup>             </drawingimage.drawing>         </drawingimage>          <drawingimage x:key="big_red_star">             <drawingimage.drawing>                 <drawinggroup>                     <drawinggroup.children>                         <geometrydrawing brush="red" geometry="f1 m 26.0781,32c 25.9941,32.0436 16.0823,24.6277 15.9983,24.6277c 15.9143,24.6277 5.96055,32.0436 5.91855,32c 5.83455,31.9564 9.48848,19.7856 9.44648,19.6983c 9.44648,19.6111 -0.0453207,12.4133 -0.00332647,12.326c -0.00332647,12.2388 11.7564,12.3697 11.8404,12.326c 11.8824,12.2824 15.9143,0.0243702 15.9983,0.0243702c 16.0823,0.0243702 20.0723,12.2824 20.1142,12.326c 20.1982,12.3697 31.958,12.2388 32,12.326c 32,12.4133 22.5082,19.6111 22.5082,19.6983c 22.4662,19.7856 26.1201,31.9564 26.0781,32 z "/>                     </drawinggroup.children>                 </drawinggroup>             </drawingimage.drawing>         </drawingimage>     </window.resources>      <stackpanel x:name="layoutroot">         <stackpanel orientation="horizontal">                 <textblock text="stretch=none" width="100"/>                         <image source="{staticresource big_red_star}"    width="32" stretch="none"/>                 <image source="{staticresource small_blue_star}" width="32" stretch="none"/>         </stackpanel>         <stackpanel orientation="horizontal">                 <textblock text="stretch=uniform" width="100"/>                  <image source="{staticresource big_red_star}"    width="32" stretch="uniform" />                 <image source="{staticresource small_blue_star}" width="32" stretch="uniform"/>                  </stackpanel>     </stackpanel> </window> 


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -