Win32 API 日本語リファレンス
ホームUI.ColorSystem › GetPS2ColorRenderingDictionary

GetPS2ColorRenderingDictionary

関数
プロファイルからPostScript2色再現辞書を取得する。
DLLmscms.dll呼出規約winapi

シグネチャ

// mscms.dll
#include <windows.h>

BOOL GetPS2ColorRenderingDictionary(
    INT_PTR hProfile,
    DWORD dwIntent,
    BYTE* pPS2ColorRenderingDictionary,   // optional
    DWORD* pcbPS2ColorRenderingDictionary,
    BOOL* pbBinary
);

パラメーター

名前方向説明
hProfileINT_PTRinPostScript色レンダリング辞書(CRD)を生成する元のカラープロファイルハンドル。
dwIntentDWORDin使用するレンダリングインテントを指定する値。
pPS2ColorRenderingDictionaryBYTE*outoptional生成されたCRDデータを受け取るバッファ。NULL可でサイズ問い合わせ。
pcbPS2ColorRenderingDictionaryDWORD*inout入出力としてバッファサイズを受け渡すポインタ。必要サイズが返る。
pbBinaryBOOL*inout出力データがバイナリ形式かを示すBOOL値へのポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

// mscms.dll
#include <windows.h>

BOOL GetPS2ColorRenderingDictionary(
    INT_PTR hProfile,
    DWORD dwIntent,
    BYTE* pPS2ColorRenderingDictionary,   // optional
    DWORD* pcbPS2ColorRenderingDictionary,
    BOOL* pbBinary
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", ExactSpelling = true)]
static extern bool GetPS2ColorRenderingDictionary(
    IntPtr hProfile,   // INT_PTR
    uint dwIntent,   // DWORD
    IntPtr pPS2ColorRenderingDictionary,   // BYTE* optional, out
    ref uint pcbPS2ColorRenderingDictionary,   // DWORD* in/out
    ref bool pbBinary   // BOOL* in/out
);
<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function GetPS2ColorRenderingDictionary(
    hProfile As IntPtr,   ' INT_PTR
    dwIntent As UInteger,   ' DWORD
    pPS2ColorRenderingDictionary As IntPtr,   ' BYTE* optional, out
    ByRef pcbPS2ColorRenderingDictionary As UInteger,   ' DWORD* in/out
    ByRef pbBinary As Boolean   ' BOOL* in/out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hProfile : INT_PTR
' dwIntent : DWORD
' pPS2ColorRenderingDictionary : BYTE* optional, out
' pcbPS2ColorRenderingDictionary : DWORD* in/out
' pbBinary : BOOL* in/out
Declare PtrSafe Function GetPS2ColorRenderingDictionary Lib "mscms" ( _
    ByVal hProfile As LongPtr, _
    ByVal dwIntent As Long, _
    ByVal pPS2ColorRenderingDictionary As LongPtr, _
    ByRef pcbPS2ColorRenderingDictionary As Long, _
    ByRef pbBinary As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetPS2ColorRenderingDictionary = ctypes.windll.mscms.GetPS2ColorRenderingDictionary
GetPS2ColorRenderingDictionary.restype = wintypes.BOOL
GetPS2ColorRenderingDictionary.argtypes = [
    ctypes.c_ssize_t,  # hProfile : INT_PTR
    wintypes.DWORD,  # dwIntent : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # pPS2ColorRenderingDictionary : BYTE* optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcbPS2ColorRenderingDictionary : DWORD* in/out
    ctypes.c_void_p,  # pbBinary : BOOL* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mscms.dll')
GetPS2ColorRenderingDictionary = Fiddle::Function.new(
  lib['GetPS2ColorRenderingDictionary'],
  [
    Fiddle::TYPE_INTPTR_T,  # hProfile : INT_PTR
    -Fiddle::TYPE_INT,  # dwIntent : DWORD
    Fiddle::TYPE_VOIDP,  # pPS2ColorRenderingDictionary : BYTE* optional, out
    Fiddle::TYPE_VOIDP,  # pcbPS2ColorRenderingDictionary : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # pbBinary : BOOL* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mscms")]
extern "system" {
    fn GetPS2ColorRenderingDictionary(
        hProfile: isize,  // INT_PTR
        dwIntent: u32,  // DWORD
        pPS2ColorRenderingDictionary: *mut u8,  // BYTE* optional, out
        pcbPS2ColorRenderingDictionary: *mut u32,  // DWORD* in/out
        pbBinary: *mut i32  // BOOL* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll")]
public static extern bool GetPS2ColorRenderingDictionary(IntPtr hProfile, uint dwIntent, IntPtr pPS2ColorRenderingDictionary, ref uint pcbPS2ColorRenderingDictionary, ref bool pbBinary);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_GetPS2ColorRenderingDictionary' -Namespace Win32 -PassThru
# $api::GetPS2ColorRenderingDictionary(hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary)
#uselib "mscms.dll"
#func global GetPS2ColorRenderingDictionary "GetPS2ColorRenderingDictionary" sptr, sptr, sptr, sptr, sptr
; GetPS2ColorRenderingDictionary hProfile, dwIntent, varptr(pPS2ColorRenderingDictionary), varptr(pcbPS2ColorRenderingDictionary), varptr(pbBinary)   ; 戻り値は stat
; hProfile : INT_PTR -> "sptr"
; dwIntent : DWORD -> "sptr"
; pPS2ColorRenderingDictionary : BYTE* optional, out -> "sptr"
; pcbPS2ColorRenderingDictionary : DWORD* in/out -> "sptr"
; pbBinary : BOOL* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mscms.dll"
#cfunc global GetPS2ColorRenderingDictionary "GetPS2ColorRenderingDictionary" sptr, int, var, var, var
; res = GetPS2ColorRenderingDictionary(hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary)
; hProfile : INT_PTR -> "sptr"
; dwIntent : DWORD -> "int"
; pPS2ColorRenderingDictionary : BYTE* optional, out -> "var"
; pcbPS2ColorRenderingDictionary : DWORD* in/out -> "var"
; pbBinary : BOOL* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetPS2ColorRenderingDictionary(INT_PTR hProfile, DWORD dwIntent, BYTE* pPS2ColorRenderingDictionary, DWORD* pcbPS2ColorRenderingDictionary, BOOL* pbBinary)
#uselib "mscms.dll"
#cfunc global GetPS2ColorRenderingDictionary "GetPS2ColorRenderingDictionary" intptr, int, var, var, var
; res = GetPS2ColorRenderingDictionary(hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary)
; hProfile : INT_PTR -> "intptr"
; dwIntent : DWORD -> "int"
; pPS2ColorRenderingDictionary : BYTE* optional, out -> "var"
; pcbPS2ColorRenderingDictionary : DWORD* in/out -> "var"
; pbBinary : BOOL* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procGetPS2ColorRenderingDictionary = mscms.NewProc("GetPS2ColorRenderingDictionary")
)

// hProfile (INT_PTR), dwIntent (DWORD), pPS2ColorRenderingDictionary (BYTE* optional, out), pcbPS2ColorRenderingDictionary (DWORD* in/out), pbBinary (BOOL* in/out)
r1, _, err := procGetPS2ColorRenderingDictionary.Call(
	uintptr(hProfile),
	uintptr(dwIntent),
	uintptr(pPS2ColorRenderingDictionary),
	uintptr(pcbPS2ColorRenderingDictionary),
	uintptr(pbBinary),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetPS2ColorRenderingDictionary(
  hProfile: NativeInt;   // INT_PTR
  dwIntent: DWORD;   // DWORD
  pPS2ColorRenderingDictionary: Pointer;   // BYTE* optional, out
  pcbPS2ColorRenderingDictionary: Pointer;   // DWORD* in/out
  pbBinary: Pointer   // BOOL* in/out
): BOOL; stdcall;
  external 'mscms.dll' name 'GetPS2ColorRenderingDictionary';
result := DllCall("mscms\GetPS2ColorRenderingDictionary"
    , "Ptr", hProfile   ; INT_PTR
    , "UInt", dwIntent   ; DWORD
    , "Ptr", pPS2ColorRenderingDictionary   ; BYTE* optional, out
    , "Ptr", pcbPS2ColorRenderingDictionary   ; DWORD* in/out
    , "Ptr", pbBinary   ; BOOL* in/out
    , "Int")   ; return: BOOL
●GetPS2ColorRenderingDictionary(hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary) = DLL("mscms.dll", "bool GetPS2ColorRenderingDictionary(int, dword, void*, void*, void*)")
# 呼び出し: GetPS2ColorRenderingDictionary(hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary)
# hProfile : INT_PTR -> "int"
# dwIntent : DWORD -> "dword"
# pPS2ColorRenderingDictionary : BYTE* optional, out -> "void*"
# pcbPS2ColorRenderingDictionary : DWORD* in/out -> "void*"
# pbBinary : BOOL* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "mscms" fn GetPS2ColorRenderingDictionary(
    hProfile: isize, // INT_PTR
    dwIntent: u32, // DWORD
    pPS2ColorRenderingDictionary: [*c]u8, // BYTE* optional, out
    pcbPS2ColorRenderingDictionary: [*c]u32, // DWORD* in/out
    pbBinary: [*c]i32 // BOOL* in/out
) callconv(std.os.windows.WINAPI) i32;
proc GetPS2ColorRenderingDictionary(
    hProfile: int,  # INT_PTR
    dwIntent: uint32,  # DWORD
    pPS2ColorRenderingDictionary: ptr uint8,  # BYTE* optional, out
    pcbPS2ColorRenderingDictionary: ptr uint32,  # DWORD* in/out
    pbBinary: ptr int32  # BOOL* in/out
): int32 {.importc: "GetPS2ColorRenderingDictionary", stdcall, dynlib: "mscms.dll".}
pragma(lib, "mscms");
extern(Windows)
int GetPS2ColorRenderingDictionary(
    ptrdiff_t hProfile,   // INT_PTR
    uint dwIntent,   // DWORD
    ubyte* pPS2ColorRenderingDictionary,   // BYTE* optional, out
    uint* pcbPS2ColorRenderingDictionary,   // DWORD* in/out
    int* pbBinary   // BOOL* in/out
);
ccall((:GetPS2ColorRenderingDictionary, "mscms.dll"), stdcall, Int32,
      (Int, UInt32, Ptr{UInt8}, Ptr{UInt32}, Ptr{Int32}),
      hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary)
# hProfile : INT_PTR -> Int
# dwIntent : DWORD -> UInt32
# pPS2ColorRenderingDictionary : BYTE* optional, out -> Ptr{UInt8}
# pcbPS2ColorRenderingDictionary : DWORD* in/out -> Ptr{UInt32}
# pbBinary : BOOL* in/out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetPS2ColorRenderingDictionary(
    intptr_t hProfile,
    uint32_t dwIntent,
    uint8_t* pPS2ColorRenderingDictionary,
    uint32_t* pcbPS2ColorRenderingDictionary,
    int32_t* pbBinary);
]]
local mscms = ffi.load("mscms")
-- mscms.GetPS2ColorRenderingDictionary(hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary)
-- hProfile : INT_PTR
-- dwIntent : DWORD
-- pPS2ColorRenderingDictionary : BYTE* optional, out
-- pcbPS2ColorRenderingDictionary : DWORD* in/out
-- pbBinary : BOOL* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const GetPS2ColorRenderingDictionary = lib.func('__stdcall', 'GetPS2ColorRenderingDictionary', 'int32_t', ['intptr_t', 'uint32_t', 'uint8_t *', 'uint32_t *', 'int32_t *']);
// GetPS2ColorRenderingDictionary(hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary)
// hProfile : INT_PTR -> 'intptr_t'
// dwIntent : DWORD -> 'uint32_t'
// pPS2ColorRenderingDictionary : BYTE* optional, out -> 'uint8_t *'
// pcbPS2ColorRenderingDictionary : DWORD* in/out -> 'uint32_t *'
// pbBinary : BOOL* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("mscms.dll", {
  GetPS2ColorRenderingDictionary: { parameters: ["isize", "u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetPS2ColorRenderingDictionary(hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary)
// hProfile : INT_PTR -> "isize"
// dwIntent : DWORD -> "u32"
// pPS2ColorRenderingDictionary : BYTE* optional, out -> "pointer"
// pcbPS2ColorRenderingDictionary : DWORD* in/out -> "pointer"
// pbBinary : BOOL* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetPS2ColorRenderingDictionary(
    intptr_t hProfile,
    uint32_t dwIntent,
    uint8_t* pPS2ColorRenderingDictionary,
    uint32_t* pcbPS2ColorRenderingDictionary,
    int32_t* pbBinary);
C, "mscms.dll");
// $ffi->GetPS2ColorRenderingDictionary(hProfile, dwIntent, pPS2ColorRenderingDictionary, pcbPS2ColorRenderingDictionary, pbBinary);
// hProfile : INT_PTR
// dwIntent : DWORD
// pPS2ColorRenderingDictionary : BYTE* optional, out
// pcbPS2ColorRenderingDictionary : DWORD* in/out
// pbBinary : BOOL* in/out
// 構造体/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);
    boolean GetPS2ColorRenderingDictionary(
        long hProfile,   // INT_PTR
        int dwIntent,   // DWORD
        byte[] pPS2ColorRenderingDictionary,   // BYTE* optional, out
        IntByReference pcbPS2ColorRenderingDictionary,   // DWORD* in/out
        IntByReference pbBinary   // BOOL* in/out
    );
}
@[Link("mscms")]
lib Libmscms
  fun GetPS2ColorRenderingDictionary = GetPS2ColorRenderingDictionary(
    hProfile : LibC::SSizeT,   # INT_PTR
    dwIntent : UInt32,   # DWORD
    pPS2ColorRenderingDictionary : UInt8*,   # BYTE* optional, out
    pcbPS2ColorRenderingDictionary : UInt32*,   # DWORD* in/out
    pbBinary : Int32*   # BOOL* in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetPS2ColorRenderingDictionaryNative = Int32 Function(IntPtr, Uint32, Pointer<Uint8>, Pointer<Uint32>, Pointer<Int32>);
typedef GetPS2ColorRenderingDictionaryDart = int Function(int, int, Pointer<Uint8>, Pointer<Uint32>, Pointer<Int32>);
final GetPS2ColorRenderingDictionary = DynamicLibrary.open('mscms.dll')
    .lookupFunction<GetPS2ColorRenderingDictionaryNative, GetPS2ColorRenderingDictionaryDart>('GetPS2ColorRenderingDictionary');
// hProfile : INT_PTR -> IntPtr
// dwIntent : DWORD -> Uint32
// pPS2ColorRenderingDictionary : BYTE* optional, out -> Pointer<Uint8>
// pcbPS2ColorRenderingDictionary : DWORD* in/out -> Pointer<Uint32>
// pbBinary : BOOL* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetPS2ColorRenderingDictionary(
  hProfile: NativeInt;   // INT_PTR
  dwIntent: DWORD;   // DWORD
  pPS2ColorRenderingDictionary: Pointer;   // BYTE* optional, out
  pcbPS2ColorRenderingDictionary: Pointer;   // DWORD* in/out
  pbBinary: Pointer   // BOOL* in/out
): BOOL; stdcall;
  external 'mscms.dll' name 'GetPS2ColorRenderingDictionary';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetPS2ColorRenderingDictionary"
  c_GetPS2ColorRenderingDictionary :: CIntPtr -> Word32 -> Ptr Word8 -> Ptr Word32 -> Ptr CInt -> IO CInt
-- hProfile : INT_PTR -> CIntPtr
-- dwIntent : DWORD -> Word32
-- pPS2ColorRenderingDictionary : BYTE* optional, out -> Ptr Word8
-- pcbPS2ColorRenderingDictionary : DWORD* in/out -> Ptr Word32
-- pbBinary : BOOL* in/out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getps2colorrenderingdictionary =
  foreign "GetPS2ColorRenderingDictionary"
    (intptr_t @-> uint32_t @-> (ptr uint8_t) @-> (ptr uint32_t) @-> (ptr int32_t) @-> returning int32_t)
(* hProfile : INT_PTR -> intptr_t *)
(* dwIntent : DWORD -> uint32_t *)
(* pPS2ColorRenderingDictionary : BYTE* optional, out -> (ptr uint8_t) *)
(* pcbPS2ColorRenderingDictionary : DWORD* in/out -> (ptr uint32_t) *)
(* pbBinary : BOOL* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mscms (t "mscms.dll"))
(cffi:use-foreign-library mscms)

(cffi:defcfun ("GetPS2ColorRenderingDictionary" get-ps2-color-rendering-dictionary :convention :stdcall) :int32
  (h-profile :int64)   ; INT_PTR
  (dw-intent :uint32)   ; DWORD
  (p-ps2-color-rendering-dictionary :pointer)   ; BYTE* optional, out
  (pcb-ps2-color-rendering-dictionary :pointer)   ; DWORD* in/out
  (pb-binary :pointer))   ; BOOL* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetPS2ColorRenderingDictionary = Win32::API::More->new('mscms',
    'BOOL GetPS2ColorRenderingDictionary(LPARAM hProfile, DWORD dwIntent, LPVOID pPS2ColorRenderingDictionary, LPVOID pcbPS2ColorRenderingDictionary, LPVOID pbBinary)');
# my $ret = $GetPS2ColorRenderingDictionary->Call($hProfile, $dwIntent, $pPS2ColorRenderingDictionary, $pcbPS2ColorRenderingDictionary, $pbBinary);
# hProfile : INT_PTR -> LPARAM
# dwIntent : DWORD -> DWORD
# pPS2ColorRenderingDictionary : BYTE* optional, out -> LPVOID
# pcbPS2ColorRenderingDictionary : DWORD* in/out -> LPVOID
# pbBinary : BOOL* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。