This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using Newtonsoft.Json; | |
using System.Linq; | |
namespace GradleLicensePluginReportJsonToMd | |
{ | |
public static class Parser | |
{ | |
public static string ParseToMd(string path) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Specialized; | |
using System.ComponentModel; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Interactivity; | |
namespace BehaviorSample.Views.Behaviors | |
{ | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>netstandard1.4</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)ProjectItemsSchema.xaml" /> | |
<ProjectCapability Include="DynamicDependentFile" /> | |
</ItemGroup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="WpfApplication1.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:local="clr-namespace:WpfApplication1" | |
mc:Ignorable="d" | |
Title="MainWindow" Height="350" Width="525"> | |
<StackPanel> | |
<TextBox Text="{Binding Hoge, Mode=TwoWay}"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ComPtr<IWICBitmapSource> bitmapSource = ReadFile(stream); // 読み込みは適当に | |
UINT width; | |
UINT height; | |
ThrowIfFailed(bitmapSource->GetSize(&width, &height)); | |
auto bitmapBytes = ref new Array<byte>(width * height * 4); // 32bpp前提 | |
ThrowIfFailed( | |
bitmapSource->CopyPixels(nullptr, width * 4, bitmapBytes->Length, bitmapBytes->Data) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 変換結果の描写 | |
var stride = transform.Size.Width * 4; //横1行のバイト数 | |
var size = stride * transform.Size.Height; | |
var bytes = new byte[size]; | |
transform.CopyPixels(bytes, stride); | |
// SharpDX.WIC.BitmapSourceをWritableBitmapに変換 | |
var bitmap = new WriteableBitmap(transform.Size.Width, transform.Size.Height); | |
using (var s = bitmap.PixelBuffer.AsStream()) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 色変換 | |
SharpDX.WIC.BitmapSource transformSource = frame; | |
if (untaggedOrUnsupported) // TryGetColorContextsの結果 | |
{ | |
// プロファイルが読み込めなかった場合はsRGBを適用するため32bppPBGRAへ変換 | |
var converter = new FormatConverter(factory); | |
converter.Initialize(frame, PixelFormat.Format32bppPBGRA); | |
transformSource = converter; | |
} | |
var transform = new ColorTransform(factory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 埋め込みプロファイル取得 | |
var stream = await File.OpenReadAsync(); // StorageFile | |
var decoder = new BitmapDecoder(factory, stream.AsStream(), DecodeOptions.CacheOnDemand); | |
var frame = decoder.GetFrame(0); // 1フレーム目のみ取得 | |
var srcContexts = frame.TryGetColorContexts(factory); | |
// GetColorContexts未対応コーデックだとnull、プロファイルが無いと長さ0となる | |
var untaggedOrUnsupported = srcContexts == null || srcContexts.Length < 1; | |
var sRGBColorContext = new ColorContext(factory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ※物理ディスプレイがない環境だと例外を吐く | |
var profileStream = await DisplayInformation.GetForCurrentView().GetColorProfileAsync(); | |
var profileBytes = new byte[profileStream.Size]; | |
var reader = new DataReader(profileStream); | |
await reader.LoadAsync((uint)profileStream.Size); | |
reader.ReadBytes(profileBytes); | |
var factory = new ImagingFactory(); | |
var displayProfile = new ColorContext(factory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows.Media.Imaging; | |
namespace GetColorContexts | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var frame = BitmapFrame.Create( |
NewerOlder