Added SKImage.IsLazyGenerated to help with cases like #445
This commit is contained in:
Родитель
9aef280082
Коммит
eb629db98b
|
@ -355,6 +355,8 @@ namespace SkiaSharp
|
|||
|
||||
public bool IsTextureBacked => SkiaApi.sk_image_is_texture_backed (Handle);
|
||||
|
||||
public bool IsLazyGenerated => SkiaApi.sk_image_is_lazy_generated (Handle);
|
||||
|
||||
public bool ReadPixels (SKImageInfo dstInfo, IntPtr dstPixels, int dstRowBytes, int srcX, int srcY)
|
||||
{
|
||||
return ReadPixels (dstInfo, dstPixels, dstRowBytes, srcX, srcY, SKImageCachingHint.Allow);
|
||||
|
|
|
@ -552,6 +552,9 @@ namespace SkiaSharp
|
|||
public extern static bool sk_image_is_texture_backed(sk_image_t image);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public extern static bool sk_image_is_lazy_generated(sk_image_t image);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public extern static bool sk_image_read_pixels(sk_image_t image, ref SKImageInfoNative dstInfo, IntPtr dstPixels, IntPtr dstRowBytes, int srcX, int srcY, SKImageCachingHint cachingHint);
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
|
|
|
@ -1129,6 +1129,24 @@
|
|||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="IsLazyGenerated">
|
||||
<MemberSignature Language="C#" Value="public bool IsLazyGenerated { get; }" />
|
||||
<MemberSignature Language="ILAsm" Value=".property instance bool IsLazyGenerated" />
|
||||
<MemberType>Property</MemberType>
|
||||
<AssemblyInfo>
|
||||
<AssemblyVersion>1.60.0.0</AssemblyVersion>
|
||||
</AssemblyInfo>
|
||||
<ReturnValue>
|
||||
<ReturnType>System.Boolean</ReturnType>
|
||||
</ReturnValue>
|
||||
<Docs>
|
||||
<summary>Gets a value indicating whether the image is backed by an image-generator or other source that creates (and caches) its pixels / texture on-demand.</summary>
|
||||
<value>
|
||||
<para></para>
|
||||
</value>
|
||||
<remarks>If this method returns <see langword="false" />, then <see cref="M:SkiaSharp.SKImage.PeekPixels" /> will return <see langword="null" />.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="PeekPixels">
|
||||
<MemberSignature Language="C#" Value="public SkiaSharp.SKPixmap PeekPixels ();" />
|
||||
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class SkiaSharp.SKPixmap PeekPixels() cil managed" />
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2ef76f9178eb9d9d97064f164ac055913d07b79c
|
||||
Subproject commit 176bd71755347e14ff59f3fe6fe125af800c3c8e
|
|
@ -1,10 +1,35 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
|
||||
namespace SkiaSharp.Tests
|
||||
{
|
||||
public class SKImageTest : SKTest
|
||||
{
|
||||
[SkippableFact]
|
||||
public void TestLazyImage()
|
||||
{
|
||||
var data = SKData.Create(Path.Combine(PathToImages, "baboon.jpg"));
|
||||
Assert.NotNull(data);
|
||||
|
||||
var image = SKImage.FromEncodedData(data);
|
||||
Assert.NotNull(image);
|
||||
|
||||
Assert.True(image.IsLazyGenerated);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void TestNotLazyImage()
|
||||
{
|
||||
var bitmap = CreateTestBitmap();
|
||||
Assert.NotNull(bitmap);
|
||||
|
||||
var image = SKImage.FromBitmap(bitmap);
|
||||
Assert.NotNull(image);
|
||||
|
||||
Assert.False(image.IsLazyGenerated);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void EncodeWithSimpleSerializer()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче