mirror of https://github.com/SixLabors/ImageSharp
committed by
GitHub
322 changed files with 1958 additions and 516 deletions
@ -0,0 +1,2 @@ |
|||
@echo Off |
|||
call build\build.cmd |
|||
@ -0,0 +1,445 @@ |
|||
// <copyright file="Program.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ConsoleApplication |
|||
{ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Text; |
|||
|
|||
using LibGit2Sharp; |
|||
using Microsoft.DotNet.ProjectModel; |
|||
using Newtonsoft.Json; |
|||
using NuGet.Versioning; |
|||
|
|||
/// <summary>
|
|||
/// This updates the version numbers for all the projects in the src folder.
|
|||
/// The version number it will geneate is dependent on if this is a build from master or a branch/PR
|
|||
///
|
|||
/// If its a build on master
|
|||
/// We take the version number specified in project.json,
|
|||
/// count how meny commits the repo has had that will affect this project or its dependencies since the version number of manually changed
|
|||
/// If this is the first commit that effected this project since number change then leave the version number as defined i.e. will build 1.0.0 if thats in project.json
|
|||
/// unless it is a preview build number in which case we always add the counter
|
|||
///
|
|||
/// If the build is from a PR/branch
|
|||
/// We take the version number specified in project.json, append a tag for the branch/PR (so we can determin how each package was built)
|
|||
/// append number of commits effecting the project.
|
|||
///
|
|||
/// </summary>
|
|||
/// <example>
|
|||
/// for PR#123 and project.json version 2.0.1 and we have had 30 commits affecting the project
|
|||
/// we would end up with version number 2.0.1-PR124-00030
|
|||
///
|
|||
/// for branch `fix-stuff` project.json version 2.0.1-alpha1 and we have had 832 commits affecting the project
|
|||
/// we would end up with version number 2.0.1-alpha1-fix-stuff-00832
|
|||
///
|
|||
/// for `master` project.json version 2.0.1-alpha1 and we have had 832 commits affecting the project
|
|||
/// we would end up with version number 2.0.1-alpha1-00832
|
|||
///
|
|||
/// for `master` project.json version 2.0.1 and we have had 132 commits affecting the project
|
|||
/// we would end up with version number 2.0.1-CI-00132
|
|||
///
|
|||
/// for `master` project.json version 2.0.1 and we have had 1 commits affecting the project
|
|||
/// we would end up with version number 2.0.1
|
|||
///
|
|||
/// for `master` project.json version 2.0.1-alpha1 and we have had 1 commits affecting the project
|
|||
/// we would end up with version number 2.0.1-alpha1
|
|||
/// </example>
|
|||
/// <remarks>
|
|||
/// TODO Add the option for using this to update the version numbers in a project and its dependent references.
|
|||
/// </remarks>
|
|||
public class Program |
|||
{ |
|||
private const string FallbackTag = "CI"; |
|||
|
|||
/// <summary>
|
|||
/// Main entry point.
|
|||
/// </summary>
|
|||
/// <param name="args">The arguments.</param>
|
|||
public static void Main(string[] args) |
|||
{ |
|||
var resetmode = args.Contains("reset"); |
|||
|
|||
// Find the project root where glbal.json lives
|
|||
var root = ProjectRootResolver.ResolveRootDirectory("."); |
|||
|
|||
// Lets find the repo
|
|||
var repo = new LibGit2Sharp.Repository(root); |
|||
|
|||
// Lets find all the project.json files in the src folder (don't care about versioning `tests`)
|
|||
var projectFiles = Directory.EnumerateFiles(Path.Combine(root, "src"), Project.FileName, SearchOption.AllDirectories); |
|||
|
|||
// Open them and convert them to source projects
|
|||
var projects = projectFiles.Select(x => ProjectReader.GetProject(x)) |
|||
.Select(x => new SourceProject(x, repo.Info.WorkingDirectory)) |
|||
.ToList(); |
|||
|
|||
if (resetmode) |
|||
{ |
|||
ResetProject(projects); |
|||
} |
|||
else |
|||
{ |
|||
CaclulateProjectVersionNumber(projects, repo); |
|||
|
|||
UpdateVersionNumbers(projects); |
|||
|
|||
CreateBuildScript(projects); |
|||
|
|||
foreach (var p in projects) |
|||
{ |
|||
Console.WriteLine($"{p.Name} {p.FinalVersionNumber}"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private static void CreateBuildScript(IEnumerable<SourceProject> projects) |
|||
{ |
|||
var sb = new StringBuilder(); |
|||
foreach (var p in projects) |
|||
{ |
|||
sb.AppendLine($@"dotnet pack --configuration Release --output ""artifacts\bin\ImageSharp"" ""{p.ProjectFilePath}"""); |
|||
} |
|||
|
|||
File.WriteAllText("build-inner.cmd", sb.ToString()); |
|||
} |
|||
|
|||
private static void UpdateVersionNumbers(IEnumerable<SourceProject> projects) |
|||
{ |
|||
foreach (var p in projects) |
|||
{ |
|||
// TODO force update of all dependent projects to point to the newest build.
|
|||
// we skip the build number and standard CI prefix on first commits
|
|||
var newVersion = p.FinalVersionNumber; |
|||
|
|||
// create a backup file so we can rollback later without breaking formatting
|
|||
File.Copy(p.FullProjectFilePath, $"{p.FullProjectFilePath}.bak", true); |
|||
|
|||
dynamic projectFile = JsonConvert.DeserializeObject(File.ReadAllText(p.FullProjectFilePath)); |
|||
|
|||
projectFile.version = $"{newVersion}-*"; |
|||
File.WriteAllText(p.FullProjectFilePath, JsonConvert.SerializeObject(projectFile, Formatting.Indented)); |
|||
} |
|||
} |
|||
|
|||
private static string CurrentBranch(Repository repo) |
|||
{ |
|||
// lets build version friendly commit
|
|||
string branch = repo.Head.FriendlyName; |
|||
|
|||
// lets see if we are running in appveyor and if we are use the environment variables instead of the head
|
|||
var appveryorBranch = Environment.GetEnvironmentVariable("APPVEYOR_REPO_BRANCH"); |
|||
if (!string.IsNullOrWhiteSpace(appveryorBranch)) |
|||
{ |
|||
branch = appveryorBranch; |
|||
} |
|||
|
|||
var prNumber = Environment.GetEnvironmentVariable("APPVEYOR_PULL_REQUEST_NUMBER"); |
|||
if (!string.IsNullOrWhiteSpace(prNumber)) |
|||
{ |
|||
branch = $"PR{int.Parse(prNumber):000}"; |
|||
} |
|||
|
|||
// this will happen when checking out a comit directly and not a branch (like appveryor does when it builds)
|
|||
if (branch == "(no branch)") |
|||
{ |
|||
throw new Exception("unable to find branch"); |
|||
} |
|||
|
|||
// clean branch names (might need to be improved)
|
|||
branch = branch.Replace("/", "-").Replace("--", "-"); |
|||
|
|||
return branch; |
|||
} |
|||
|
|||
private static void CaclulateProjectVersionNumber(List<SourceProject> projects, Repository repo) |
|||
{ |
|||
var branch = CurrentBranch(repo); |
|||
|
|||
// populate the dependency chains
|
|||
projects.ForEach(x => x.PopulateDependencies(projects)); |
|||
|
|||
// update the final version based on the repo history and the currentr branch name
|
|||
projects.ForEach(x => x.CalculateVersion(repo, branch)); |
|||
} |
|||
|
|||
private static void ResetProject(List<SourceProject> projects) |
|||
{ |
|||
if (File.Exists("build-inner.cmd")) |
|||
{ |
|||
File.Delete("build-inner.cmd"); |
|||
} |
|||
|
|||
// revert the project.json change be reverting it but skipp all the git stuff as its not needed
|
|||
foreach (var p in projects) |
|||
{ |
|||
if (File.Exists($"{p.FullProjectFilePath}.bak")) |
|||
{ |
|||
File.Copy($"{p.FullProjectFilePath}.bak", p.FullProjectFilePath, true); |
|||
File.Delete($"{p.FullProjectFilePath}.bak"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Project level logic
|
|||
/// </summary>
|
|||
public class SourceProject |
|||
{ |
|||
private readonly IEnumerable<string> dependencies; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="SourceProject"/> class.
|
|||
/// </summary>
|
|||
/// <param name="project">The project.</param>
|
|||
/// <param name="root">The root.</param>
|
|||
public SourceProject(Project project, string root) |
|||
{ |
|||
this.Name = project.Name; |
|||
this.ProjectDirectory = project.ProjectDirectory.Substring(root.Length); |
|||
this.ProjectFilePath = project.ProjectFilePath.Substring(root.Length); |
|||
this.FullProjectFilePath = project.ProjectFilePath; |
|||
this.Version = project.Version; |
|||
this.dependencies = project.Dependencies.Select(x => x.Name); |
|||
this.FinalVersionNumber = this.Version.ToFullString(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the project directory.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The project directory.
|
|||
/// </value>
|
|||
public string ProjectDirectory { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the version.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The version.
|
|||
/// </value>
|
|||
public NuGetVersion Version { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the dependent projects.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The dependent projects.
|
|||
/// </value>
|
|||
public List<SourceProject> DependentProjects { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the name.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The name.
|
|||
/// </value>
|
|||
public string Name { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the project file path.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The project file path.
|
|||
/// </value>
|
|||
public string ProjectFilePath { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the commit count since version change.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The commit count since version change.
|
|||
/// </value>
|
|||
public int CommitCountSinceVersionChange { get; private set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// Gets the full project file path.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The full project file path.
|
|||
/// </value>
|
|||
public string FullProjectFilePath { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the final version number.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The final version number.
|
|||
/// </value>
|
|||
public string FinalVersionNumber { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// Populates the dependencies.
|
|||
/// </summary>
|
|||
/// <param name="projects">The projects.</param>
|
|||
public void PopulateDependencies(IEnumerable<SourceProject> projects) |
|||
{ |
|||
this.DependentProjects = projects.Where(x => this.dependencies.Contains(x.Name)).ToList(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Calculates the version.
|
|||
/// </summary>
|
|||
/// <param name="repo">The repo.</param>
|
|||
/// <param name="branch">The branch.</param>
|
|||
internal void CalculateVersion(Repository repo, string branch) |
|||
{ |
|||
foreach (var c in repo.Commits) |
|||
{ |
|||
if (!this.ApplyCommit(c, repo)) |
|||
{ |
|||
// we have finished lets populate the final version number
|
|||
this.FinalVersionNumber = this.CalculateVersionNumber(branch); |
|||
|
|||
return; |
|||
} |
|||
} |
|||
} |
|||
|
|||
private bool MatchPath(string path) |
|||
{ |
|||
if (path.StartsWith(this.ProjectDirectory, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
if (this.DependentProjects.Any()) |
|||
{ |
|||
return this.DependentProjects.Any(x => x.MatchPath(path)); |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
private bool ApplyCommitInternal(Commit commit, TreeChanges changes, Repository repo) |
|||
{ |
|||
this.CommitCountSinceVersionChange++; |
|||
|
|||
// return false if this is a version number root
|
|||
var projectFileChange = changes.Where(x => x.Path?.Equals(this.ProjectFilePath, StringComparison.OrdinalIgnoreCase) == true).FirstOrDefault(); |
|||
if (projectFileChange != null) |
|||
{ |
|||
if (projectFileChange.Status == ChangeKind.Added) |
|||
{ |
|||
// the version must have been set here
|
|||
return false; |
|||
} |
|||
else |
|||
{ |
|||
var blob = repo.Lookup<Blob>(projectFileChange.Oid); |
|||
using (var s = blob.GetContentStream()) |
|||
{ |
|||
var project = new ProjectReader().ReadProject(s, this.Name, this.FullProjectFilePath, null); |
|||
if (project.Version != this.Version) |
|||
{ |
|||
// version changed
|
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
// version must have been the same lets carry on
|
|||
return true; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
private bool ApplyCommit(Commit commit, Repository repo) |
|||
{ |
|||
foreach (var parent in commit.Parents) |
|||
{ |
|||
var changes = repo.Diff.Compare<TreeChanges>(parent.Tree, commit.Tree); |
|||
|
|||
foreach (TreeEntryChanges change in changes) |
|||
{ |
|||
if (!string.IsNullOrWhiteSpace(change.OldPath)) |
|||
{ |
|||
if (this.MatchPath(change.OldPath)) |
|||
{ |
|||
return this.ApplyCommitInternal(commit, changes, repo); |
|||
} |
|||
} |
|||
|
|||
if (!string.IsNullOrWhiteSpace(change.Path)) |
|||
{ |
|||
if (this.MatchPath(change.Path)) |
|||
{ |
|||
return this.ApplyCommitInternal(commit, changes, repo); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
private string CalculateVersionNumber(string branch) |
|||
{ |
|||
var version = this.Version.ToFullString(); |
|||
|
|||
// master only
|
|||
if (this.CommitCountSinceVersionChange == 1 && branch == "master") |
|||
{ |
|||
if (this.Version.IsPrerelease) |
|||
{ |
|||
// prerelease always needs the build counter just not on a branch name
|
|||
return $"{version}-{this.CommitCountSinceVersionChange:00000}"; |
|||
} |
|||
|
|||
// this is the full release happy path, first commit after changing the version number
|
|||
return version; |
|||
} |
|||
|
|||
var rootSpecialVersion = string.Empty; |
|||
|
|||
if (this.Version.IsPrerelease) |
|||
{ |
|||
// probably a much easy way for doing this but it work sell enough for a build script
|
|||
var parts = version.Split(new[] { '-' }, 2); |
|||
version = parts[0]; |
|||
rootSpecialVersion = parts[1]; |
|||
} |
|||
|
|||
// if master and the version doesn't manually specify a prerelease tag force one on for CI builds
|
|||
if (branch == "master") |
|||
{ |
|||
if (!this.Version.IsPrerelease) |
|||
{ |
|||
branch = FallbackTag; |
|||
} |
|||
else |
|||
{ |
|||
branch = string.Empty; |
|||
} |
|||
} |
|||
|
|||
if (rootSpecialVersion.Length > 0) |
|||
{ |
|||
rootSpecialVersion = "-" + rootSpecialVersion; |
|||
} |
|||
|
|||
if (branch.Length > 0) |
|||
{ |
|||
branch = "-" + branch; |
|||
} |
|||
|
|||
var maxLength = 20; // dotnet will fail to populate the package if the tag is > 20
|
|||
maxLength -= rootSpecialVersion.Length; // this is a required tag
|
|||
maxLength -= 7; // for the counter and dashes
|
|||
|
|||
if (branch.Length > maxLength) |
|||
{ |
|||
branch = branch.Substring(0, maxLength); |
|||
} |
|||
|
|||
return $"{version}{rootSpecialVersion}{branch}-{this.CommitCountSinceVersionChange:00000}"; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
{ |
|||
"profiles": { |
|||
"build": { |
|||
"commandName": "Project" |
|||
} |
|||
} |
|||
} |
|||
@ -1,13 +0,0 @@ |
|||
var jsonfile = require("jsonfile"); |
|||
var semver = require("semver"); |
|||
|
|||
var file = "../src/imagesharp/project.json"; |
|||
|
|||
var semversion = semver.valid(process.env.mssemver); |
|||
|
|||
jsonfile.readFile(file, function (err, project) { |
|||
project.version = semversion; |
|||
jsonfile.writeFile(file, project, {spaces: 2}, function(err) { |
|||
console.error(err); |
|||
}); |
|||
}) |
|||
@ -1,17 +0,0 @@ |
|||
$version=[Version]$Env:APPVEYOR_BUILD_VERSION |
|||
$version_suffix=$Env:version_suffix |
|||
|
|||
$basever=$version.Major.ToString() + "." + $version.Minor.ToString() + "." + $version.Build.ToString() |
|||
|
|||
$semver = $basever + "-" + $version_suffix + "." + $version.Revision.ToString().PadLeft(6,"0") |
|||
$mssemver = $basever + "-" + $version_suffix + "-" + $version.Revision.ToString().PadLeft(6,"0") |
|||
$appveyor_version = $mssemver |
|||
|
|||
$Env:semver = $semver |
|||
$Env:mssemver = $mssemver |
|||
$Env:appveyor_version = $appveyor_version |
|||
$Env:ms_file_version = $version.ToString() |
|||
|
|||
"Envrionment variable 'semver' set:" + $Env:semver |
|||
"Envrionment variable 'mssemver' set:" + $Env:mssemver |
|||
"Envrionment variable 'appveyor_version' set:" + $Env:appveyor_version |
|||
@ -0,0 +1,18 @@ |
|||
@echo Off |
|||
set buildRoot="%cd%" |
|||
|
|||
ECHO Restoring packages |
|||
dotnet restore |
|||
|
|||
ECHO Updating version numbers and generating build script |
|||
cd %~dp0 |
|||
dotnet run -- update |
|||
cd %buildRoot% |
|||
|
|||
ECHO Building package |
|||
call %~dp0build-inner.cmd |
|||
|
|||
ECHO Reset version numbers |
|||
cd %~dp0 |
|||
dotnet run -- reset |
|||
cd %buildRoot% |
|||
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
|||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>575a5002-dd9f-4335-aa47-1dd87fa13645</ProjectGuid> |
|||
<RootNamespace>build</RootNamespace> |
|||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
|||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
|||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> |
|||
</ItemGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
|||
</Project> |
|||
@ -1,6 +0,0 @@ |
|||
{ |
|||
"dependencies": { |
|||
"jsonfile": "^2.2.3", |
|||
"semver": "^5.0.3" |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
{ |
|||
"version": "1.0.0-*", |
|||
"buildOptions": { |
|||
"debugType": "portable", |
|||
"emitEntryPoint": true, |
|||
"xmlDoc": true, |
|||
"additionalArguments": [ "/additionalfile:../src/Shared/stylecop.json", "/ruleset:../ImageSharp.ruleset" ] |
|||
}, |
|||
"dependencies": { |
|||
"Microsoft.DotNet.ProjectModel": "1.0.0-rc3-003121", |
|||
"LibGit2Sharp": "0.23.0", |
|||
"StyleCop.Analyzers": { |
|||
"version": "1.1.0-beta001", |
|||
"type": "build" |
|||
} |
|||
}, |
|||
"frameworks": { |
|||
"net46": { |
|||
// this is only a net46 app because of LibGit2Sharp once they have a version that works on coreclr we can shift over. |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
@echo Off |
|||
|
|||
set buildRoot="%cd%" |
|||
cd %~dp0 |
|||
|
|||
dotnet run -- reset |
|||
|
|||
cd %buildRoot% |
|||
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
|||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>2e33181e-6e28-4662-a801-e2e7dc206029</ProjectGuid> |
|||
<RootNamespace>ImageSharp.Drawing</RootNamespace> |
|||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
|||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
|||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> |
|||
</ItemGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
|||
</Project> |
|||
@ -0,0 +1,6 @@ |
|||
// <copyright file="AssemblyInfo.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
// Common values read from `AssemblyInfo.Common.cs`
|
|||
@ -0,0 +1,83 @@ |
|||
{ |
|||
"version": "1.0.0-alpha1-*", |
|||
"title": "ImageSharp.Drawing", |
|||
"description": "A cross-platform library for the processing of image files; written in C#", |
|||
"authors": [ |
|||
"James Jackson-South and contributors" |
|||
], |
|||
"packOptions": { |
|||
"owners": [ |
|||
"James Jackson-South and contributors" |
|||
], |
|||
"projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", |
|||
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", |
|||
"iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", |
|||
"requireLicenseAcceptance": false, |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "https://github.com/JimBobSquarePants/ImageSharp" |
|||
}, |
|||
"tags": [ |
|||
"Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" |
|||
] |
|||
}, |
|||
"buildOptions": { |
|||
"allowUnsafe": true, |
|||
"xmlDoc": true, |
|||
"additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], |
|||
"compile": [ |
|||
"../Shared/*.cs" |
|||
] |
|||
}, |
|||
"configurations": { |
|||
"Release": { |
|||
"buildOptions": { |
|||
"warningsAsErrors": true, |
|||
"optimize": true |
|||
} |
|||
} |
|||
}, |
|||
"dependencies": { |
|||
"ImageSharp": { |
|||
"target": "project", |
|||
"version": "1.0.0-*" |
|||
}, |
|||
"ImageSharp.Processing": { |
|||
"target": "project", |
|||
"version": "1.0.0-*" |
|||
}, |
|||
"StyleCop.Analyzers": { |
|||
"version": "1.0.0", |
|||
"type": "build" |
|||
}, |
|||
"System.Buffers": "4.0.0", |
|||
"System.Numerics.Vectors": "4.1.1", |
|||
"System.Runtime.CompilerServices.Unsafe": "4.0.0" |
|||
}, |
|||
"frameworks": { |
|||
"netstandard1.1": { |
|||
"dependencies": { |
|||
"System.Collections": "4.0.11", |
|||
"System.Diagnostics.Debug": "4.0.11", |
|||
"System.Diagnostics.Tools": "4.0.1", |
|||
"System.IO": "4.1.0", |
|||
"System.IO.Compression": "4.1.0", |
|||
"System.Linq": "4.1.0", |
|||
"System.ObjectModel": "4.0.12", |
|||
"System.Resources.ResourceManager": "4.0.1", |
|||
"System.Runtime.Extensions": "4.1.0", |
|||
"System.Runtime.InteropServices": "4.1.0", |
|||
"System.Runtime.Numerics": "4.0.1", |
|||
"System.Text.Encoding.Extensions": "4.0.11", |
|||
"System.Threading": "4.0.11", |
|||
"System.Threading.Tasks": "4.0.11", |
|||
"System.Threading.Tasks.Parallel": "4.0.1" |
|||
} |
|||
}, |
|||
"net45": { |
|||
"dependencies": { |
|||
"System.Runtime": "4.0.0" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
// <copyright file="ImageExtensions.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp |
|||
{ |
|||
using System; |
|||
using System.IO; |
|||
|
|||
using Formats; |
|||
|
|||
/// <summary>
|
|||
/// Extension methods for the <see cref="Image{TColor}"/> type.
|
|||
/// </summary>
|
|||
public static partial class ImageExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Saves the image to the given stream with the bmp format.
|
|||
/// </summary>
|
|||
/// <typeparam name="TColor">The pixel format.</typeparam>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="stream">The stream to save the image to.</param>
|
|||
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
|
|||
/// <returns>
|
|||
/// The <see cref="Image{TColoR}"/>.
|
|||
/// </returns>
|
|||
public static Image<TColor> SaveAsBmp<TColor>(this Image<TColor> source, Stream stream) |
|||
where TColor : struct, IPackedPixel, IEquatable<TColor> |
|||
=> source.Save(stream, new BmpEncoder()); |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
|||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>c77661b9-f793-422e-8e27-ac60ecc5f215</ProjectGuid> |
|||
<RootNamespace>ImageSharp.Formats.Bmp</RootNamespace> |
|||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
|||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
|||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> |
|||
</ItemGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
|||
</Project> |
|||
@ -0,0 +1,6 @@ |
|||
// <copyright file="AssemblyInfo.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
// Common values read from `AssemblyInfo.Common.cs`
|
|||
@ -0,0 +1,81 @@ |
|||
{ |
|||
"version": "1.0.0-alpha1-*", |
|||
"title": "ImageSharp.Formats.Bmp", |
|||
"description": "A cross-platform library for the processing of image files; written in C#", |
|||
"authors": [ |
|||
"James Jackson-South and contributors" |
|||
], |
|||
"packOptions": { |
|||
"owners": [ |
|||
"James Jackson-South and contributors" |
|||
], |
|||
"projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", |
|||
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", |
|||
"iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", |
|||
"requireLicenseAcceptance": false, |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "https://github.com/JimBobSquarePants/ImageSharp" |
|||
}, |
|||
"tags": [ |
|||
"Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" |
|||
] |
|||
}, |
|||
"buildOptions": { |
|||
"allowUnsafe": true, |
|||
"xmlDoc": true, |
|||
"additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], |
|||
"compile": [ |
|||
"../Shared/*.cs" |
|||
] |
|||
}, |
|||
"configurations": { |
|||
"Release": { |
|||
"buildOptions": { |
|||
"warningsAsErrors": true, |
|||
"optimize": true |
|||
} |
|||
} |
|||
}, |
|||
"dependencies": { |
|||
"ImageSharp": { |
|||
"target": "project", |
|||
"version": "1.0.0-*" |
|||
}, |
|||
"StyleCop.Analyzers": { |
|||
"version": "1.1.0-beta001", |
|||
"type": "build" |
|||
}, |
|||
"System.Buffers": "4.0.0", |
|||
"System.Numerics.Vectors": "4.1.1", |
|||
"System.Runtime.CompilerServices.Unsafe": "4.0.0" |
|||
}, |
|||
"frameworks": { |
|||
"netstandard1.1": { |
|||
"dependencies": { |
|||
"System.Collections": "4.0.11", |
|||
"System.Diagnostics.Debug": "4.0.11", |
|||
"System.Diagnostics.Tools": "4.0.1", |
|||
"System.IO": "4.1.0", |
|||
"System.IO.Compression": "4.1.0", |
|||
"System.Linq": "4.1.0", |
|||
"System.ObjectModel": "4.0.12", |
|||
"System.Resources.ResourceManager": "4.0.1", |
|||
"System.Runtime.Extensions": "4.1.0", |
|||
"System.Runtime.InteropServices": "4.1.0", |
|||
"System.Runtime.Numerics": "4.0.1", |
|||
"System.Text.Encoding.Extensions": "4.0.11", |
|||
"System.Threading": "4.0.11", |
|||
"System.Threading.Tasks": "4.0.11", |
|||
"System.Threading.Tasks.Parallel": "4.0.1" |
|||
} |
|||
}, |
|||
"net45": { |
|||
"dependencies": { |
|||
"System.Runtime": "4.0.0", |
|||
"System.IO": "4.0.0", |
|||
"System.Threading.Tasks.Parallel": "4.0.0" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
// <copyright file="ImageExtensions.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp |
|||
{ |
|||
using System; |
|||
using System.IO; |
|||
|
|||
using Formats; |
|||
|
|||
/// <summary>
|
|||
/// Extension methods for the <see cref="Image{TColor}"/> type.
|
|||
/// </summary>
|
|||
public static partial class ImageExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Saves the image to the given stream with the gif format.
|
|||
/// </summary>
|
|||
/// <typeparam name="TColor">The pixel format.</typeparam>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="stream">The stream to save the image to.</param>
|
|||
/// <param name="quality">The quality to save the image to representing the number of colors. Between 1 and 256.</param>
|
|||
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
|
|||
/// <returns>
|
|||
/// The <see cref="Image{TColor}"/>.
|
|||
/// </returns>
|
|||
public static Image<TColor> SaveAsGif<TColor>(this Image<TColor> source, Stream stream, int quality = 256) |
|||
where TColor : struct, IPackedPixel, IEquatable<TColor> |
|||
=> source.Save(stream, new GifEncoder { Quality = quality }); |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
|||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>27ad4b5f-ecc4-4c63-9ecb-04ec772fdb6f</ProjectGuid> |
|||
<RootNamespace>ImageSharp.Formats.Gif</RootNamespace> |
|||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
|||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
|||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> |
|||
</ItemGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
|||
</Project> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue