WcsCreateIccProfile
関数シグネチャ
// mscms.dll
#include <windows.h>
INT_PTR WcsCreateIccProfile(
INT_PTR hWcsProfile,
DWORD dwOptions
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| hWcsProfile | INT_PTR | in | 変換する WCS カラープロファイルのハンドル。「解説」を参照してください。 | ||||||
| dwOptions | DWORD | in | プロファイルの変換オプションを指定するフラグ値。 既定では、変換に使用された元の WCS プロファイルは、Microsoft のプライベートタグ WcsProfilesTag (シグネチャは "MS000") として出力の ICC プロファイルに埋め込まれます。これにより、ICC 対応ソフトウェアと互換性を保ちながら、元の WCS プロファイルデータを解析するように設計されたコードからも利用できる ICC プロファイルが生成されます。 このパラメーターに指定できる値は次のとおりです。この一覧に定義されていないビットはすべて予約済みであり、0 に設定する必要があります:
|
戻り値の型: INT_PTR
公式ドキュメント
WCS プロファイルを International Color Consortium (ICC) プロファイルに変換します。
戻り値
この関数が成功した場合、戻り値は新しいカラープロファイルのハンドルです。
この関数が失敗した場合、戻り値は NULL です。詳細なエラー情報を取得するには、GetLastError を呼び出します。
解説(Remarks)
この関数は、ASCII 文字列と Unicode 文字列のどちらでも使用できます。
返された HPROFILE ハンドルが不要になったら、CloseColorProfile 関数を使用して閉じる必要があります。
HPROFILE に含まれる DMP、CAMP、GMMP は、作成された ICC プロファイル内のプライベートタグに埋め込まれます。
この API を使用して作成された ICC プロファイルのプロファイル説明タグは、WCS プロファイルの ProfileName 要素から次のパターンに従って構成されます: "Created by Microsoft WCS from DMP:[DMP の ProfileName], CAMP:[CAMP の ProfileName], GMMP:[GMMP の ProfileName]"
WCS がこの ICC プロファイルを検出すると (OpenColorProfileW または WcsOpenColorProfileW を介して)、WcsProfilesTag に含まれる WCS プロファイルを抽出して使用します。
WCS で作成されるガマットタグ内の色域外 (out-of-gamut) 情報には、CIECAM02 における知覚的な色差、すなわち CIECAM02 Jab 空間における二乗平均平方根が使用されます。従来の ICC プロファイルのガマットタグにおける距離は、CIELAB 空間における二乗平均平方根です。知覚的により正確な距離の尺度が得られるため、利用可能な場合は CIECAM02 空間を使用することをお勧めします。
WCS は、デバイスに明示的に関連付けられた XML プロファイル、または WcsProfilesTag を持つ ICC プロファイルによって、元の WCS プロファイルを抽出して使用します。
WcsProfilesTag は、WcsCreateIccProfile によって作成されたプロファイルにおいて、WcsCreateIccProfile への入力となった WCS プロファイルを格納するために使用される Microsoft のプライベート ICC プロファイルタグです。このタグは、プロファイルタグに関する ICC プロファイルの要件に準拠しています。タグの XML 以外の構成要素は、ICC プロファイルの標準である「ビッグエンディアン」のバイト順である必要があります。さらに、タグデータは (ICC プロファイルの先頭から測って) 4 バイト境界に整列している必要があります。タグの構造は、以下の WcsProfilesTagType によって定義されます。なお、タグの XML 構成要素、つまり WcsProfileTag に含まれる WCS プロファイルは、本来のバイト順のまま残されます。XML パーサーはリトルエンディアンとビッグエンディアンのどちらも正しく処理できるため、そのいずれかになります。
WcsProfilesTag のシグネチャは "MS00" です。これは、WcsProfilesTag について ICC プロファイルのタグテーブルに現れるタグシグネチャです。
WcsProfilesTagType 構造体の構造は次のとおりです:
| バイトオフセット | 内容 |
|---|---|
| 0-3 | MS10 型シグネチャ。 |
| 4-7 | 予約済み。0 に設定する必要があります (ICC の慣例)。 |
| 8-11 | タグの先頭から CDMP データまでのバイトオフセット。 |
| 12-15 | CDMP データのサイズ (バイト単位)。 |
| 16-19 | タグの先頭から CAMP データまでのバイトオフセット。 |
| 20-23 | CAMP データのサイズ (バイト単位)。 |
| 24-27 | タグの先頭から GMMP データまでのバイトオフセット。 |
| 28-31 | タグの先頭から GMMP データまでのバイトオフセット。 |
| 31-n | (要素サイズ - 32) バイトのシーケンス [要素サイズは、このタグについて ICC プロファイルのタグテーブルのエントリに記録されているタグサイズです。] |
これらは、この ICC プロファイルを作成するために WcsCreateIccProfile が使用した WCS XML プロファイルです。WCS プロファイルは、DMP (必須) が最初、次に CAMP (存在する場合)、次に GMMP (存在する場合) の順に並びます。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// mscms.dll
#include <windows.h>
INT_PTR WcsCreateIccProfile(
INT_PTR hWcsProfile,
DWORD dwOptions
);[DllImport("mscms.dll", ExactSpelling = true)]
static extern IntPtr WcsCreateIccProfile(
IntPtr hWcsProfile, // INT_PTR
uint dwOptions // DWORD
);<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function WcsCreateIccProfile(
hWcsProfile As IntPtr, ' INT_PTR
dwOptions As UInteger ' DWORD
) As IntPtr
End Function' hWcsProfile : INT_PTR
' dwOptions : DWORD
Declare PtrSafe Function WcsCreateIccProfile Lib "mscms" ( _
ByVal hWcsProfile As LongPtr, _
ByVal dwOptions As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WcsCreateIccProfile = ctypes.windll.mscms.WcsCreateIccProfile
WcsCreateIccProfile.restype = ctypes.c_ssize_t
WcsCreateIccProfile.argtypes = [
ctypes.c_ssize_t, # hWcsProfile : INT_PTR
wintypes.DWORD, # dwOptions : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mscms.dll')
WcsCreateIccProfile = Fiddle::Function.new(
lib['WcsCreateIccProfile'],
[
Fiddle::TYPE_INTPTR_T, # hWcsProfile : INT_PTR
-Fiddle::TYPE_INT, # dwOptions : DWORD
],
Fiddle::TYPE_INTPTR_T)#[link(name = "mscms")]
extern "system" {
fn WcsCreateIccProfile(
hWcsProfile: isize, // INT_PTR
dwOptions: u32 // DWORD
) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("mscms.dll")]
public static extern IntPtr WcsCreateIccProfile(IntPtr hWcsProfile, uint dwOptions);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_WcsCreateIccProfile' -Namespace Win32 -PassThru
# $api::WcsCreateIccProfile(hWcsProfile, dwOptions)#uselib "mscms.dll"
#func global WcsCreateIccProfile "WcsCreateIccProfile" sptr, sptr
; WcsCreateIccProfile hWcsProfile, dwOptions ; 戻り値は stat
; hWcsProfile : INT_PTR -> "sptr"
; dwOptions : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "mscms.dll"
#cfunc global WcsCreateIccProfile "WcsCreateIccProfile" sptr, int
; res = WcsCreateIccProfile(hWcsProfile, dwOptions)
; hWcsProfile : INT_PTR -> "sptr"
; dwOptions : DWORD -> "int"; INT_PTR WcsCreateIccProfile(INT_PTR hWcsProfile, DWORD dwOptions)
#uselib "mscms.dll"
#cfunc global WcsCreateIccProfile "WcsCreateIccProfile" intptr, int
; res = WcsCreateIccProfile(hWcsProfile, dwOptions)
; hWcsProfile : INT_PTR -> "intptr"
; dwOptions : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscms = windows.NewLazySystemDLL("mscms.dll")
procWcsCreateIccProfile = mscms.NewProc("WcsCreateIccProfile")
)
// hWcsProfile (INT_PTR), dwOptions (DWORD)
r1, _, err := procWcsCreateIccProfile.Call(
uintptr(hWcsProfile),
uintptr(dwOptions),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INT_PTRfunction WcsCreateIccProfile(
hWcsProfile: NativeInt; // INT_PTR
dwOptions: DWORD // DWORD
): NativeInt; stdcall;
external 'mscms.dll' name 'WcsCreateIccProfile';result := DllCall("mscms\WcsCreateIccProfile"
, "Ptr", hWcsProfile ; INT_PTR
, "UInt", dwOptions ; DWORD
, "Ptr") ; return: INT_PTR●WcsCreateIccProfile(hWcsProfile, dwOptions) = DLL("mscms.dll", "int WcsCreateIccProfile(int, dword)")
# 呼び出し: WcsCreateIccProfile(hWcsProfile, dwOptions)
# hWcsProfile : INT_PTR -> "int"
# dwOptions : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mscms" fn WcsCreateIccProfile(
hWcsProfile: isize, // INT_PTR
dwOptions: u32 // DWORD
) callconv(std.os.windows.WINAPI) isize;proc WcsCreateIccProfile(
hWcsProfile: int, # INT_PTR
dwOptions: uint32 # DWORD
): int {.importc: "WcsCreateIccProfile", stdcall, dynlib: "mscms.dll".}pragma(lib, "mscms");
extern(Windows)
ptrdiff_t WcsCreateIccProfile(
ptrdiff_t hWcsProfile, // INT_PTR
uint dwOptions // DWORD
);ccall((:WcsCreateIccProfile, "mscms.dll"), stdcall, Int,
(Int, UInt32),
hWcsProfile, dwOptions)
# hWcsProfile : INT_PTR -> Int
# dwOptions : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
intptr_t WcsCreateIccProfile(
intptr_t hWcsProfile,
uint32_t dwOptions);
]]
local mscms = ffi.load("mscms")
-- mscms.WcsCreateIccProfile(hWcsProfile, dwOptions)
-- hWcsProfile : INT_PTR
-- dwOptions : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const WcsCreateIccProfile = lib.func('__stdcall', 'WcsCreateIccProfile', 'intptr_t', ['intptr_t', 'uint32_t']);
// WcsCreateIccProfile(hWcsProfile, dwOptions)
// hWcsProfile : INT_PTR -> 'intptr_t'
// dwOptions : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mscms.dll", {
WcsCreateIccProfile: { parameters: ["isize", "u32"], result: "isize" },
});
// lib.symbols.WcsCreateIccProfile(hWcsProfile, dwOptions)
// hWcsProfile : INT_PTR -> "isize"
// dwOptions : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
intptr_t WcsCreateIccProfile(
intptr_t hWcsProfile,
uint32_t dwOptions);
C, "mscms.dll");
// $ffi->WcsCreateIccProfile(hWcsProfile, dwOptions);
// hWcsProfile : INT_PTR
// dwOptions : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Mscms extends StdCallLibrary {
Mscms INSTANCE = Native.load("mscms", Mscms.class);
long WcsCreateIccProfile(
long hWcsProfile, // INT_PTR
int dwOptions // DWORD
);
}@[Link("mscms")]
lib Libmscms
fun WcsCreateIccProfile = WcsCreateIccProfile(
hWcsProfile : LibC::SSizeT, # INT_PTR
dwOptions : UInt32 # DWORD
) : LibC::SSizeT
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WcsCreateIccProfileNative = IntPtr Function(IntPtr, Uint32);
typedef WcsCreateIccProfileDart = int Function(int, int);
final WcsCreateIccProfile = DynamicLibrary.open('mscms.dll')
.lookupFunction<WcsCreateIccProfileNative, WcsCreateIccProfileDart>('WcsCreateIccProfile');
// hWcsProfile : INT_PTR -> IntPtr
// dwOptions : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WcsCreateIccProfile(
hWcsProfile: NativeInt; // INT_PTR
dwOptions: DWORD // DWORD
): NativeInt; stdcall;
external 'mscms.dll' name 'WcsCreateIccProfile';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WcsCreateIccProfile"
c_WcsCreateIccProfile :: CIntPtr -> Word32 -> IO CIntPtr
-- hWcsProfile : INT_PTR -> CIntPtr
-- dwOptions : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wcscreateiccprofile =
foreign "WcsCreateIccProfile"
(intptr_t @-> uint32_t @-> returning intptr_t)
(* hWcsProfile : INT_PTR -> intptr_t *)
(* dwOptions : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mscms (t "mscms.dll"))
(cffi:use-foreign-library mscms)
(cffi:defcfun ("WcsCreateIccProfile" wcs-create-icc-profile :convention :stdcall) :int64
(h-wcs-profile :int64) ; INT_PTR
(dw-options :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WcsCreateIccProfile = Win32::API::More->new('mscms',
'LPARAM WcsCreateIccProfile(LPARAM hWcsProfile, DWORD dwOptions)');
# my $ret = $WcsCreateIccProfile->Call($hWcsProfile, $dwOptions);
# hWcsProfile : INT_PTR -> LPARAM
# dwOptions : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。