Before opening, meet the four different property values of stretch:
Many of the apps now have avatars or other UI designs that are rounded and, of course, have a block-shaped metro style layout. In the Win10 phone preview version.
The contact avatar is changed to a circular display. I really do not know what Microsoft think, some of their own creation or initiation of things themselves do not insist, and then be
Apple's Android, this is not to make a dowry for others. It's disciplining how the market got up.
Forget it, a lot of crap, in the programmer's view, there is a need to achieve, there must be a way to achieve. The simple method is as follows:
Two ways, the former universal, the latter heavy in optimization.
<Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </grid.rowde finitions> <grid grid.row= "0" > <ellipse height= "$" width= ">" <Ellipse.Fill> <imagebrush imagesource= "assets/images/icon.jpg" stretch= "UniformToFill"/> </ellipse. fill> </Ellipse> </Grid> <grid grid.row= "1" > <ellipse height= "$" width= "200" > <Ellipse.Fill> <ImageBrush> <ImageBrush.ImageSource> <bitmapimage decodepixelheight= "" "Decodepixelwidth=" urisource= "Assets/images/icon.jpg"/&G T </ImageBrush.ImageSource> <ImageBrush.Stretch> <stretch>unifor mtofill</stretch> </ImageBrush.Stretch> </ImageBrush> </ ElLipse. Fill> </Ellipse> </Grid></Grid>
Established display effect:
The above two methods, at first glance no difference. That's more than Decodepixelheight and decodepixelwidth. These two property settings. And the latter is for
Memory-saving presence. Imagine such two cases:
Situation one: If your original picture is a computer wallpaper, the equivalent of 1920*1200, and you show a circle image or avatar only need to show one of them
Points, then your initial load, the application to use this image needs to be decoded, so large a picture, decoding will consume a lot of memory. Of course this
The situation does not usually appear, our pre-set image must have been cropped to the appropriate size. But this situation also needs to be taken into account.
Situation two: When we display a large number of such circular images, such as the application shows a lot of user information, it is inevitable that the user's picture of the centralized display,
And even if you preset the size of the picture is appropriate, but when the number is supreme, the nature is very memory-intensive, the program will also collapse.
So based on two scenarios, we can summarize the difference between the two methods is whether the ImageBrush is based on the actual size of rendering the picture this area
Don't , and the actual use of ImageBrush will not be automatically based on the need to render the size to decode the function. So what do we do to make it real?
Size to render the picture? That's the two attributes that helped. That's why Decodepixelheight and decodepixelwidth are good partners.
Of It's pretty useful for memory optimizations.
Here is a quote:
Note: This feature is automatically decoded based on the need to render size, even if a picture is larger, but only the size that needs to be rendered is decoded. So, as
You have a 2000 pixel multiplied by 2000 pixel size picture, but just need to render 100 pixels multiplied by 100 pixel size, we will
By decoding the image to 100 pixels multiplied by 100 pixels, you can save a lot of memory.
Recommended Links:
Bitmapimage.decodepixeltype Property
Bitmapimage.downloadprogress Event
The difference between making, optimizing, and stretch four property values for a circular picture or avatar in Windows Phone 8.1