зеркало из https://github.com/mono/SkiaSharp.git
Updated the UWP sample
This commit is contained in:
Родитель
6e8fe68ea5
Коммит
76c80146f1
|
@ -449,6 +449,53 @@ namespace SkiaSharp
|
|||
}
|
||||
}
|
||||
|
||||
public static void DngDecoder(SKCanvas canvas, int width, int height)
|
||||
{
|
||||
var assembly = typeof(Demos).GetTypeInfo().Assembly;
|
||||
var imageName = assembly.GetName().Name + ".adobe-dng.dng";
|
||||
|
||||
canvas.Clear(SKColors.White);
|
||||
|
||||
// load the embedded resource stream
|
||||
using (var resource = assembly.GetManifestResourceStream(imageName))
|
||||
using (var stream = new SKManagedStream(resource))
|
||||
using (var codec = SKCodec.Create(stream))
|
||||
using (var paint = new SKPaint())
|
||||
using (var tf = SKTypeface.FromFamilyName("Arial"))
|
||||
{
|
||||
var info = codec.Info;
|
||||
|
||||
paint.IsAntialias = true;
|
||||
paint.TextSize = 14;
|
||||
paint.Typeface = tf;
|
||||
paint.Color = SKColors.Black;
|
||||
|
||||
// decode the image
|
||||
using (var bitmap = new SKBitmap(info.Width, info.Height, info.ColorType, info.IsOpaque ? SKAlphaType.Opaque : SKAlphaType.Premul))
|
||||
{
|
||||
IntPtr length;
|
||||
var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels(out length));
|
||||
if (result == SKCodecResult.Success || result == SKCodecResult.IncompleteInput)
|
||||
{
|
||||
var x = 25;
|
||||
var y = 25;
|
||||
|
||||
canvas.DrawBitmap(bitmap, SKRect.Create (x, y, bitmap.Width / 2, bitmap.Height / 2));
|
||||
x += bitmap.Width / 2 + 25;
|
||||
y += 14;
|
||||
|
||||
canvas.DrawText(string.Format("Result: {0}", result), x, y, paint);
|
||||
y += 20;
|
||||
|
||||
canvas.DrawText(string.Format("Size: {0}px x {1}px", bitmap.Width, bitmap.Height), x, y, paint);
|
||||
y += 20;
|
||||
|
||||
canvas.DrawText(string.Format("Pixels: {0} @ {1}b/px", bitmap.Pixels.Length, bitmap.BytesPerPixel), x, y, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void BitmapDecoder(SKCanvas canvas, int width, int height)
|
||||
{
|
||||
var assembly = typeof(Demos).GetTypeInfo().Assembly;
|
||||
|
@ -994,6 +1041,7 @@ namespace SkiaSharp
|
|||
new Sample {Title="Bitmap Shader", Method = BitmapShader, Platform = Platform.All},
|
||||
new Sample {Title="Bitmap Shader (Manipulated)", Method = BitmapShaderManipulated, Platform = Platform.All},
|
||||
new Sample {Title="Bitmap Decoder", Method = BitmapDecoder, Platform = Platform.All},
|
||||
new Sample {Title="Bitmap Decoder (DNG)", Method = DngDecoder, Platform = Platform.All},
|
||||
new Sample {Title="Sweep Gradient Shader", Method = SweepGradientShader, Platform = Platform.All},
|
||||
new Sample {Title="Fractal Perlin Noise Shader", Method = FractalPerlinNoiseShader, Platform = Platform.All},
|
||||
new Sample {Title="Turbulence Perlin Noise Shader", Method = TurbulencePerlinNoiseShader, Platform = Platform.All},
|
||||
|
|
Двоичный файл не отображается.
|
@ -96,6 +96,9 @@
|
|||
<EmbeddedResource Include="..\SharedDemo\color-wheel.png">
|
||||
<Link>color-wheel.png</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="..\SharedDemo\adobe-dng.dng">
|
||||
<Link>adobe-dng.dng</Link>
|
||||
</EmbeddedResource>
|
||||
<Content Include="..\SharedDemo\content-font.ttf">
|
||||
<Link>content-font.ttf</Link>
|
||||
</Content>
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Skia.WindowsDesktop.Demo
|
|||
|
||||
try
|
||||
{
|
||||
using (var surface = SKSurface.Create(width, height, SKColorType.N_32, SKAlphaType.Premul, buff, width * 4))
|
||||
using (var surface = SKSurface.Create(width, height, SKImageInfo.PlatformColorType, SKAlphaType.Premul, buff, width * 4))
|
||||
{
|
||||
var skcanvas = surface.Canvas;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче