Skip to content

Instantly share code, notes, and snippets.

@veigr
Created January 22, 2015 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veigr/024c4f7139f6c17c6d56 to your computer and use it in GitHub Desktop.
Save veigr/024c4f7139f6c17c6d56 to your computer and use it in GitHub Desktop.
[WPF]埋め込みプロファイルの取得
using System;
using System.Windows.Media.Imaging;
namespace GetColorContexts
{
class Program
{
static void Main(string[] args)
{
var frame = BitmapFrame.Create(
new Uri(@"C:\Hoge.jpg"),
// IgnoreColorProfileを指定しないとsRGBに変換される
BitmapCreateOptions.IgnoreColorProfile
// PreservePixelFormatを指定しないとCMYK画像がRGBなPixelFormatに変換される
| BitmapCreateOptions.PreservePixelFormat,
// None以外で読み込んだ場合、その時に指定したBitmapCreateOptionsで画像がキャッシュされ、
// キャッシュから再読込される時のBitmapCreateOptionsが無視されてしまう
BitmapCacheOption.None
);
// 埋め込みプロファイル取得
var contexts = frame.ColorContexts;
foreach (var context in contexts)
{
// 埋め込みプロファイルのProfileUriは空っぽ
Console.WriteLine(context.ProfileUri);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment