Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lindexi_gd
Uno
提交
9773ee52
U
Uno
项目概览
lindexi_gd
/
Uno
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
Uno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9773ee52
编写于
4月 05, 2023
作者:
J
Jérôme Laban
提交者:
GitHub
4月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11885 from unoplatform/dev/sb/imagebrush-bitmap-ios
fix: Ensure imagebrush's source is updated when set
上级
b9d0f8e1
6a56be0f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
88 addition
and
0 deletion
+88
-0
src/Uno.UI.RuntimeTests/Helpers/ImageAssert.cs
src/Uno.UI.RuntimeTests/Helpers/ImageAssert.cs
+19
-0
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Imaging/Given_BitmapSource.cs
...Tests/Windows_UI_Xaml_Media_Imaging/Given_BitmapSource.cs
+67
-0
src/Uno.UI/UI/Xaml/Media/Brush.iOSmacOS.cs
src/Uno.UI/UI/Xaml/Media/Brush.iOSmacOS.cs
+2
-0
未找到文件。
src/Uno.UI.RuntimeTests/Helpers/ImageAssert.cs
浏览文件 @
9773ee52
...
...
@@ -65,6 +65,25 @@ public static partial class ImageAssert
Assert
.
Fail
(
$"Expected '
{
ToArgbCode
(
expectedColor
)}
' in rectangle '
{
rect
}
'."
);
}
/// <summary>
/// Asserts that a given screenshot does not have a specific color anywhere within a given rectangle.
/// </summary>
public
static
void
DoesNotHaveColorInRectangle
(
RawBitmap
screenshot
,
Rectangle
rect
,
Color
excludedColor
,
byte
tolerance
=
0
,
[
CallerLineNumber
]
int
line
=
0
)
{
var
bitmap
=
screenshot
;
for
(
var
x
=
rect
.
Left
;
x
<
rect
.
Right
;
x
++)
{
for
(
var
y
=
rect
.
Top
;
y
<
rect
.
Bottom
;
y
++)
{
var
pixel
=
bitmap
.
GetPixel
(
x
,
y
);
if
(
AreSameColor
(
excludedColor
,
pixel
,
tolerance
,
out
_
))
{
Assert
.
Fail
(
$"Color '
{
ToArgbCode
(
excludedColor
)}
' was found at (
{
x
}
,
{
y
}
) in rectangle '
{
rect
}
'."
);
}
}
}
}
private
static
void
HasColorAtImpl
(
RawBitmap
screenshot
,
int
x
,
int
y
,
Color
expectedColor
,
byte
tolerance
,
int
line
)
{
var
bitmap
=
screenshot
;
...
...
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Imaging/Given_BitmapSource.cs
浏览文件 @
9773ee52
...
...
@@ -8,9 +8,18 @@ using Windows.UI.Xaml.Controls;
using
Windows.UI.Xaml.Markup
;
using
Windows.UI.Xaml.Media.Imaging
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
System.Runtime.InteropServices.WindowsRuntime
;
using
Private.Infrastructure
;
using
Windows.Storage
;
using
static
Private
.
Infrastructure
.
TestServices
;
using
Windows.UI.Xaml.Shapes
;
using
Windows.UI.Xaml.Media
;
using
Windows.UI
;
using
Uno.UI.RuntimeTests.Helpers
;
using
Uno.UI.RuntimeTests.Extensions
;
using
Windows.Foundation.Metadata
;
using
Windows.UI.Xaml
;
using
System.Linq
;
namespace
Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Media_Imaging
{
...
...
@@ -124,6 +133,64 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Media_Imaging
}
#endif
[
TestMethod
]
[
RunsOnUIThread
]
public
async
Task
When_WriteableBitmap_Assigned_With_Data_Present
()
{
if
(!
ApiInformation
.
IsTypePresent
(
"Windows.UI.Xaml.Media.Imaging.RenderTargetBitmap"
))
{
Assert
.
Inconclusive
();
// System.NotImplementedException: RenderTargetBitmap is not supported on this platform.;
}
var
wb
=
new
WriteableBitmap
(
20
,
20
);
var
parent
=
new
Border
()
{
Width
=
50
,
Height
=
50
,
Background
=
new
SolidColorBrush
(
Colors
.
Blue
),
};
var
rect
=
new
Rectangle
{
Width
=
20
,
Height
=
20
,
VerticalAlignment
=
VerticalAlignment
.
Center
,
HorizontalAlignment
=
HorizontalAlignment
.
Center
,
};
parent
.
Child
=
rect
;
WindowHelper
.
WindowContent
=
parent
;
await
WindowHelper
.
WaitForIdle
();
await
WindowHelper
.
WaitForLoaded
(
rect
);
var
bgraPixelData
=
Enumerable
.
Repeat
<
byte
>(
255
,
(
int
)
wb
.
PixelBuffer
.
Length
).
ToArray
();
using
(
Stream
stream
=
wb
.
PixelBuffer
.
AsStream
())
{
stream
.
Write
(
bgraPixelData
,
0
,
bgraPixelData
.
Length
);
}
rect
.
Fill
=
new
ImageBrush
{
ImageSource
=
wb
};
await
WindowHelper
.
WaitForIdle
();
var
renderer
=
new
RenderTargetBitmap
();
await
WindowHelper
.
WaitForIdle
();
await
renderer
.
RenderAsync
(
parent
);
var
snapshot
=
await
RawBitmap
.
From
(
renderer
,
rect
);
var
coords
=
parent
.
GetRelativeCoords
(
rect
);
await
WindowHelper
.
WaitForIdle
();
ImageAssert
.
DoesNotHaveColorInRectangle
(
snapshot
,
new
System
.
Drawing
.
Rectangle
((
int
)
coords
.
X
,
(
int
)
coords
.
Y
,
(
int
)
coords
.
Width
,
(
int
)
coords
.
Height
),
Colors
.
Blue
);
}
private
class
Given_BitmapSource_Exception
:
Exception
{
public
string
Caller
{
get
;
}
...
...
src/Uno.UI/UI/Xaml/Media/Brush.iOSmacOS.cs
浏览文件 @
9773ee52
...
...
@@ -63,6 +63,8 @@ namespace Windows.UI.Xaml.Media
else
if
(
b
is
ImageBrush
imageBrush
)
{
var
disposables
=
new
CompositeDisposable
(
5
);
imageBrushCallback
?.
Invoke
();
void
ImageChanged
(
_Image
_
)
=>
colorSetter
(
SolidColorBrushHelper
.
Transparent
.
Color
);
imageBrush
.
ImageChanged
+=
ImageChanged
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录