Merge pull request #464 from dotnet/fix-402

Rename W2DImage to PlatformImage
This commit is contained in:
jonlipsky 2022-06-30 08:06:59 -07:00 коммит произвёл GitHub
Родитель 26443e1372 755563d2bd
Коммит 56a423b29b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -7,18 +7,18 @@ using Windows.Storage.Streams;
namespace Microsoft.Maui.Graphics.Win2D namespace Microsoft.Maui.Graphics.Win2D
{ {
internal class W2DImage : IImage public class PlatformImage : IImage
{ {
private readonly ICanvasResourceCreator _creator; private readonly ICanvasResourceCreator _creator;
private CanvasBitmap _bitmap; private CanvasBitmap _bitmap;
public W2DImage(ICanvasResourceCreator creator, CanvasBitmap bitmap) public PlatformImage(ICanvasResourceCreator creator, CanvasBitmap bitmap)
{ {
_creator = creator; _creator = creator;
_bitmap = bitmap; _bitmap = bitmap;
} }
public CanvasBitmap PlatformImage => _bitmap; public CanvasBitmap Bitmap => _bitmap;
public void Dispose() public void Dispose()
{ {
@ -118,7 +118,7 @@ namespace Microsoft.Maui.Graphics.Win2D
throw new Exception("No resource creator has been registered globally or for this thread."); throw new Exception("No resource creator has been registered globally or for this thread.");
var bitmap = AsyncPump.Run(async () => await CanvasBitmap.LoadAsync(creator, stream.AsRandomAccessStream())); var bitmap = AsyncPump.Run(async () => await CanvasBitmap.LoadAsync(creator, stream.AsRandomAccessStream()));
return new W2DImage(creator, bitmap); return new PlatformImage(creator, bitmap);
} }
} }
} }

Просмотреть файл

@ -374,9 +374,9 @@ After:
if (paint is ImagePaint imagePaint) if (paint is ImagePaint imagePaint)
{ {
if (imagePaint.Image is W2DImage image) if (imagePaint.Image is PlatformImage platformImage)
{ {
var bitmapBrush = new CanvasImageBrush(_session, image.PlatformImage) var bitmapBrush = new CanvasImageBrush(_session, platformImage.Bitmap)
{ {
ExtendX = CanvasEdgeBehavior.Wrap, ExtendX = CanvasEdgeBehavior.Wrap,
ExtendY = CanvasEdgeBehavior.Wrap ExtendY = CanvasEdgeBehavior.Wrap
@ -510,17 +510,17 @@ After:
public override void DrawImage(IImage image, float x, float y, float width, float height) public override void DrawImage(IImage image, float x, float y, float width, float height)
{ {
if (image is W2DImage platformImage) if (image is PlatformImage platformImage)
{ {
SetRect(x, y, width, height); SetRect(x, y, width, height);
/* Unmerged change from project 'Microsoft.Maui.Graphics.Win2D.WinUI.Desktop' /* Unmerged change from project 'Microsoft.Maui.Graphics.Win2D.WinUI.Desktop'
Before: Before:
Draw(s => s.DrawImage(platformImage.PlatformImage, _rect, Rect.Empty, CurrentState.Alpha, CanvasImageInterpolation.Linear)); Draw(s => s.DrawImage(platformImage.Bitmap, _rect, Rect.Empty, CurrentState.Alpha, CanvasImageInterpolation.Linear));
After: After:
Draw(s => s.DrawImage(platformImage.PlatformImage, _rect, global::Windows.Foundation.Rect.Empty, CurrentState.Alpha, CanvasImageInterpolation.Linear)); Draw(s => s.DrawImage(platformImage.Bitmap, _rect, global::Windows.Foundation.Rect.Empty, CurrentState.Alpha, CanvasImageInterpolation.Linear));
*/ */
Draw(s => s.DrawImage(platformImage.PlatformImage, _rect, WRect.Empty, CurrentState.Alpha, CanvasImageInterpolation.Linear)); Draw(s => s.DrawImage(platformImage.Bitmap, _rect, WRect.Empty, CurrentState.Alpha, CanvasImageInterpolation.Linear));
} }
} }

Просмотреть файл

@ -8,7 +8,7 @@ namespace Microsoft.Maui.Graphics.Win2D
{ {
public IImage FromStream(Stream stream, ImageFormat formatHint = ImageFormat.Png) public IImage FromStream(Stream stream, ImageFormat formatHint = ImageFormat.Png)
{ {
return W2DImage.FromStream(stream, formatHint); return PlatformImage.FromStream(stream, formatHint);
} }
} }