You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this example, the image is clipped using a <xref:Microsoft.Maui.Graphics.PathF> object that defines a circle that's centered at (100,90) with a radius of 80. The result is that only the part of the image within the circle is visible:
558
613
559
614
:::image type="content" source="media/draw/clippath.png" alt-text="Screenshot of an image that's been clipped with the ClipPath method.":::
@@ -563,6 +618,8 @@ In this example, the image is clipped using a <xref:Microsoft.Maui.Graphics.Path
563
618
564
619
The following example shows how to use the <xref:Microsoft.Maui.Graphics.ICanvas.SubtractFromClip%2A> method to clip an image:
In this example, the area defined by the rectangle that's specified by the arguments supplied to the <xref:Microsoft.Maui.Graphics.ICanvas.SubtractFromClip%2A> method is clipped from the image. The result is that only the parts of the image outside the rectangle are visible:
595
677
596
678
:::image type="content" source="media/draw/subtractfromclip.png" alt-text="Screenshot of an image that's been clipped with the SubtractFromClip method.":::
In this example, the image is retrieved from the assembly and loaded as a stream. The image is resized using the <xref:Microsoft.Maui.Graphics.IImage.Resize%2A> method, with its arguments specifying the new size, and that it should be stretched to fill the available space. In addition, the source image is disposed. The resized image is then drawn at actual size at (10,10).
105
158
106
159
## Downsize an image
@@ -111,6 +164,8 @@ The <xref:Microsoft.Maui.Graphics.IImage.Downsize%2A> overloads also accept an o
111
164
112
165
The following example shows how to downsize an image:
In this example, the image is retrieved from the assembly and loaded as a stream. The image is downsized using the <xref:Microsoft.Maui.Graphics.IImage.Downsize%2A> method, with the argument specifying that its largest dimension should be set to 100 pixels. In addition, the source image is disposed. The downsized image is then drawn at actual size at (10,10).
143
223
144
224
## Save an image
@@ -150,6 +230,8 @@ You can save images using the <xref:Microsoft.Maui.Graphics.IImage.Save%2A> and
using (Streamstream=assembly.GetManifestResourceStream("GraphicsViewDemos.Resources.Images.dotnet_bot.png"))
279
+
{
280
+
image=PlatformImage.FromStream(stream);
281
+
}
282
+
283
+
// Save image to a memory stream
284
+
if (image!=null)
285
+
{
286
+
IImagenewImage=image.Downsize(150, true);
287
+
using (MemoryStreammemStream=newMemoryStream())
288
+
{
289
+
newImage.Save(memStream);
290
+
}
291
+
}
292
+
```
293
+
294
+
::: moniker-end
295
+
185
296
In this example, the image is retrieved from the assembly and loaded as a stream. The image is downsized using the <xref:Microsoft.Maui.Graphics.IImage.Downsize%2A> method, with the argument specifying that its largest dimension should be set to 150 pixels. In addition, the source image is disposed. The downsized image is then saved to a stream.
using (Streamstream=assembly.GetManifestResourceStream("GraphicsViewDemos.Resources.Images.dotnet_bot.png"))
122
+
{
123
+
image=PlatformImage.FromStream(stream);
124
+
}
125
+
126
+
if (image!=null)
127
+
{
128
+
ImagePaintimagePaint=newImagePaint
129
+
{
130
+
Image=image.Downsize(100)
131
+
};
132
+
canvas.SetFillPaint(imagePaint, RectF.Zero);
133
+
canvas.FillRectangle(0, 0, 240, 300);
134
+
}
135
+
```
136
+
137
+
::: moniker-end
138
+
108
139
In this example, the image is retrieved from the assembly and loaded as a stream. The image is resized using the <xref:Microsoft.Maui.Graphics.IImage.Downsize%2a> method, with the argument specifying that its largest dimension should be set to 100 pixels. For more information about downsizing an image, see [Downsize an image](~/user-interface/graphics/images.md#downsize-an-image).
109
140
110
141
The <xref:Microsoft.Maui.Graphics.ImagePaint.Image> property of the <xref:Microsoft.Maui.Graphics.ImagePaint> object is set to the downsized version of the image, and the <xref:Microsoft.Maui.Graphics.ImagePaint> object is set as the paint to fill an object with. A rectangle is then drawn that's filled with the paint:
Copy file name to clipboardexpand all lines: docs/whats-new/dotnet-8.md
+1
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,7 @@ The following behavior has changed from the previous release:
67
67
- How the color of a tab is set in a Shell app has changed on some platforms. For more information, see [Tab appearance](~/fundamentals/shell/tabs.md#tab-appearance).
68
68
- It's not required to specify a value for the `$(ApplicationIdGuid)` build property in your app's project file. This is because .NET MAUI Windows apps no longer require a GUID as an app ID, and instead use the value of the `$(ApplicationId)` build property as the app ID. Therefore, the same reverse domain format app ID is now used across all platforms, such as com.mycompany.myapp.
69
69
- .NET MAUI Mac Catalyst apps are no longer limited to 50 menu items on the menu bar.
70
+
- The `PlatformImage.FromStream` method, in the `Microsoft.Maui.Graphics` namespace, can now be used to load images on Windows instead of having to use the `W2DImageLoadingService` class.
0 commit comments