Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add Color and Icon samples #21

Merged
merged 1 commit into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions sample/ManualGenerate/ManualGenerate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SkiaSharp.QrCode" Version="0.3.0" />
<ProjectReference Include="..\..\src\SkiaSharp.QrCode\SkiaSharp.QrCode.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="samples\*.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
22 changes: 20 additions & 2 deletions sample/ManualGenerate/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using SkiaSharp;
using SkiaSharp;
using System;
using System.IO;
using SkiaSharp.QrCode;
using SkiaSharp.QrCode.Models;

namespace SkiaQrCodeSampleConsole
{
class Program
{
static void Main(string[] args)
{
Directory.CreateDirectory("output");

var content = "testtesttest";
using (var generator = new QRCodeGenerator())
{
Expand All @@ -22,6 +25,21 @@ static void Main(string[] args)
var canvas = surface.Canvas;
canvas.Render(qr, info.Width, info.Height);

// gen color
// yellow https://rgb.to/yellow
//canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(60,100,50));
// red https://rgb.to/red
//canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(0, 100, 50));

// gen icon
//var logo = File.ReadAllBytes("samples/test.png");
//var icon = new IconData
//{
// Icon = SKBitmap.Decode(logo),
// IconSizePercent = 10,
//};
//canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.Parse("000000"), icon);

// Output to Stream -> File
using (var image = surface.Snapshot())
using (var data = image.Encode(SKEncodedImageFormat.Png, 100))
Expand All @@ -33,4 +51,4 @@ static void Main(string[] args)
}
}
}
}
}
Binary file added sample/ManualGenerate/samples/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions sample/SimpleGenerate/SimpleGenerate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SkiaSharp.QrCode" Version="0.3.0" />
<ProjectReference Include="..\..\src\SkiaSharp.QrCode\SkiaSharp.QrCode.csproj" />
</ItemGroup>

</Project>