Win32 API 日本語リファレンス
ホームWeb.InternetExplorer › DitherTo8

DitherTo8

関数
画像ビットを8ビットカラーへディザリング変換する。
DLLImgUtil.dll呼出規約winapi

シグネチャ

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

HRESULT DitherTo8(
    BYTE* pDestBits,
    INT nDestPitch,
    BYTE* pSrcBits,
    INT nSrcPitch,
    const GUID* bfidSrc,
    RGBQUAD* prgbDestColors,
    RGBQUAD* prgbSrcColors,
    BYTE* pbDestInvMap,
    INT x,
    INT y,
    INT cx,
    INT cy,
    INT lDestTrans,
    INT lSrcTrans
);

パラメーター

名前方向
pDestBitsBYTE*inout
nDestPitchINTin
pSrcBitsBYTE*inout
nSrcPitchINTin
bfidSrcGUID*in
prgbDestColorsRGBQUAD*inout
prgbSrcColorsRGBQUAD*inout
pbDestInvMapBYTE*inout
xINTin
yINTin
cxINTin
cyINTin
lDestTransINTin
lSrcTransINTin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DitherTo8(
    BYTE* pDestBits,
    INT nDestPitch,
    BYTE* pSrcBits,
    INT nSrcPitch,
    const GUID* bfidSrc,
    RGBQUAD* prgbDestColors,
    RGBQUAD* prgbSrcColors,
    BYTE* pbDestInvMap,
    INT x,
    INT y,
    INT cx,
    INT cy,
    INT lDestTrans,
    INT lSrcTrans
);
[DllImport("ImgUtil.dll", ExactSpelling = true)]
static extern int DitherTo8(
    IntPtr pDestBits,   // BYTE* in/out
    int nDestPitch,   // INT
    IntPtr pSrcBits,   // BYTE* in/out
    int nSrcPitch,   // INT
    ref Guid bfidSrc,   // GUID*
    IntPtr prgbDestColors,   // RGBQUAD* in/out
    IntPtr prgbSrcColors,   // RGBQUAD* in/out
    IntPtr pbDestInvMap,   // BYTE* in/out
    int x,   // INT
    int y,   // INT
    int cx,   // INT
    int cy,   // INT
    int lDestTrans,   // INT
    int lSrcTrans   // INT
);
<DllImport("ImgUtil.dll", ExactSpelling:=True)>
Public Shared Function DitherTo8(
    pDestBits As IntPtr,   ' BYTE* in/out
    nDestPitch As Integer,   ' INT
    pSrcBits As IntPtr,   ' BYTE* in/out
    nSrcPitch As Integer,   ' INT
    ByRef bfidSrc As Guid,   ' GUID*
    prgbDestColors As IntPtr,   ' RGBQUAD* in/out
    prgbSrcColors As IntPtr,   ' RGBQUAD* in/out
    pbDestInvMap As IntPtr,   ' BYTE* in/out
    x As Integer,   ' INT
    y As Integer,   ' INT
    cx As Integer,   ' INT
    cy As Integer,   ' INT
    lDestTrans As Integer,   ' INT
    lSrcTrans As Integer   ' INT
) As Integer
End Function
' pDestBits : BYTE* in/out
' nDestPitch : INT
' pSrcBits : BYTE* in/out
' nSrcPitch : INT
' bfidSrc : GUID*
' prgbDestColors : RGBQUAD* in/out
' prgbSrcColors : RGBQUAD* in/out
' pbDestInvMap : BYTE* in/out
' x : INT
' y : INT
' cx : INT
' cy : INT
' lDestTrans : INT
' lSrcTrans : INT
Declare PtrSafe Function DitherTo8 Lib "imgutil" ( _
    ByVal pDestBits As LongPtr, _
    ByVal nDestPitch As Long, _
    ByVal pSrcBits As LongPtr, _
    ByVal nSrcPitch As Long, _
    ByVal bfidSrc As LongPtr, _
    ByVal prgbDestColors As LongPtr, _
    ByVal prgbSrcColors As LongPtr, _
    ByVal pbDestInvMap As LongPtr, _
    ByVal x As Long, _
    ByVal y As Long, _
    ByVal cx As Long, _
    ByVal cy As Long, _
    ByVal lDestTrans As Long, _
    ByVal lSrcTrans As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DitherTo8 = ctypes.windll.imgutil.DitherTo8
DitherTo8.restype = ctypes.c_int
DitherTo8.argtypes = [
    ctypes.POINTER(ctypes.c_ubyte),  # pDestBits : BYTE* in/out
    ctypes.c_int,  # nDestPitch : INT
    ctypes.POINTER(ctypes.c_ubyte),  # pSrcBits : BYTE* in/out
    ctypes.c_int,  # nSrcPitch : INT
    ctypes.c_void_p,  # bfidSrc : GUID*
    ctypes.c_void_p,  # prgbDestColors : RGBQUAD* in/out
    ctypes.c_void_p,  # prgbSrcColors : RGBQUAD* in/out
    ctypes.POINTER(ctypes.c_ubyte),  # pbDestInvMap : BYTE* in/out
    ctypes.c_int,  # x : INT
    ctypes.c_int,  # y : INT
    ctypes.c_int,  # cx : INT
    ctypes.c_int,  # cy : INT
    ctypes.c_int,  # lDestTrans : INT
    ctypes.c_int,  # lSrcTrans : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ImgUtil.dll')
DitherTo8 = Fiddle::Function.new(
  lib['DitherTo8'],
  [
    Fiddle::TYPE_VOIDP,  # pDestBits : BYTE* in/out
    Fiddle::TYPE_INT,  # nDestPitch : INT
    Fiddle::TYPE_VOIDP,  # pSrcBits : BYTE* in/out
    Fiddle::TYPE_INT,  # nSrcPitch : INT
    Fiddle::TYPE_VOIDP,  # bfidSrc : GUID*
    Fiddle::TYPE_VOIDP,  # prgbDestColors : RGBQUAD* in/out
    Fiddle::TYPE_VOIDP,  # prgbSrcColors : RGBQUAD* in/out
    Fiddle::TYPE_VOIDP,  # pbDestInvMap : BYTE* in/out
    Fiddle::TYPE_INT,  # x : INT
    Fiddle::TYPE_INT,  # y : INT
    Fiddle::TYPE_INT,  # cx : INT
    Fiddle::TYPE_INT,  # cy : INT
    Fiddle::TYPE_INT,  # lDestTrans : INT
    Fiddle::TYPE_INT,  # lSrcTrans : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "imgutil")]
extern "system" {
    fn DitherTo8(
        pDestBits: *mut u8,  // BYTE* in/out
        nDestPitch: i32,  // INT
        pSrcBits: *mut u8,  // BYTE* in/out
        nSrcPitch: i32,  // INT
        bfidSrc: *const GUID,  // GUID*
        prgbDestColors: *mut RGBQUAD,  // RGBQUAD* in/out
        prgbSrcColors: *mut RGBQUAD,  // RGBQUAD* in/out
        pbDestInvMap: *mut u8,  // BYTE* in/out
        x: i32,  // INT
        y: i32,  // INT
        cx: i32,  // INT
        cy: i32,  // INT
        lDestTrans: i32,  // INT
        lSrcTrans: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ImgUtil.dll")]
public static extern int DitherTo8(IntPtr pDestBits, int nDestPitch, IntPtr pSrcBits, int nSrcPitch, ref Guid bfidSrc, IntPtr prgbDestColors, IntPtr prgbSrcColors, IntPtr pbDestInvMap, int x, int y, int cx, int cy, int lDestTrans, int lSrcTrans);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ImgUtil_DitherTo8' -Namespace Win32 -PassThru
# $api::DitherTo8(pDestBits, nDestPitch, pSrcBits, nSrcPitch, bfidSrc, prgbDestColors, prgbSrcColors, pbDestInvMap, x, y, cx, cy, lDestTrans, lSrcTrans)
#uselib "ImgUtil.dll"
#func global DitherTo8 "DitherTo8" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DitherTo8 varptr(pDestBits), nDestPitch, varptr(pSrcBits), nSrcPitch, varptr(bfidSrc), varptr(prgbDestColors), varptr(prgbSrcColors), varptr(pbDestInvMap), x, y, cx, cy, lDestTrans, lSrcTrans   ; 戻り値は stat
; pDestBits : BYTE* in/out -> "sptr"
; nDestPitch : INT -> "sptr"
; pSrcBits : BYTE* in/out -> "sptr"
; nSrcPitch : INT -> "sptr"
; bfidSrc : GUID* -> "sptr"
; prgbDestColors : RGBQUAD* in/out -> "sptr"
; prgbSrcColors : RGBQUAD* in/out -> "sptr"
; pbDestInvMap : BYTE* in/out -> "sptr"
; x : INT -> "sptr"
; y : INT -> "sptr"
; cx : INT -> "sptr"
; cy : INT -> "sptr"
; lDestTrans : INT -> "sptr"
; lSrcTrans : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ImgUtil.dll"
#cfunc global DitherTo8 "DitherTo8" var, int, var, int, var, var, var, var, int, int, int, int, int, int
; res = DitherTo8(pDestBits, nDestPitch, pSrcBits, nSrcPitch, bfidSrc, prgbDestColors, prgbSrcColors, pbDestInvMap, x, y, cx, cy, lDestTrans, lSrcTrans)
; pDestBits : BYTE* in/out -> "var"
; nDestPitch : INT -> "int"
; pSrcBits : BYTE* in/out -> "var"
; nSrcPitch : INT -> "int"
; bfidSrc : GUID* -> "var"
; prgbDestColors : RGBQUAD* in/out -> "var"
; prgbSrcColors : RGBQUAD* in/out -> "var"
; pbDestInvMap : BYTE* in/out -> "var"
; x : INT -> "int"
; y : INT -> "int"
; cx : INT -> "int"
; cy : INT -> "int"
; lDestTrans : INT -> "int"
; lSrcTrans : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT DitherTo8(BYTE* pDestBits, INT nDestPitch, BYTE* pSrcBits, INT nSrcPitch, GUID* bfidSrc, RGBQUAD* prgbDestColors, RGBQUAD* prgbSrcColors, BYTE* pbDestInvMap, INT x, INT y, INT cx, INT cy, INT lDestTrans, INT lSrcTrans)
#uselib "ImgUtil.dll"
#cfunc global DitherTo8 "DitherTo8" var, int, var, int, var, var, var, var, int, int, int, int, int, int
; res = DitherTo8(pDestBits, nDestPitch, pSrcBits, nSrcPitch, bfidSrc, prgbDestColors, prgbSrcColors, pbDestInvMap, x, y, cx, cy, lDestTrans, lSrcTrans)
; pDestBits : BYTE* in/out -> "var"
; nDestPitch : INT -> "int"
; pSrcBits : BYTE* in/out -> "var"
; nSrcPitch : INT -> "int"
; bfidSrc : GUID* -> "var"
; prgbDestColors : RGBQUAD* in/out -> "var"
; prgbSrcColors : RGBQUAD* in/out -> "var"
; pbDestInvMap : BYTE* in/out -> "var"
; x : INT -> "int"
; y : INT -> "int"
; cx : INT -> "int"
; cy : INT -> "int"
; lDestTrans : INT -> "int"
; lSrcTrans : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	imgutil = windows.NewLazySystemDLL("ImgUtil.dll")
	procDitherTo8 = imgutil.NewProc("DitherTo8")
)

// pDestBits (BYTE* in/out), nDestPitch (INT), pSrcBits (BYTE* in/out), nSrcPitch (INT), bfidSrc (GUID*), prgbDestColors (RGBQUAD* in/out), prgbSrcColors (RGBQUAD* in/out), pbDestInvMap (BYTE* in/out), x (INT), y (INT), cx (INT), cy (INT), lDestTrans (INT), lSrcTrans (INT)
r1, _, err := procDitherTo8.Call(
	uintptr(pDestBits),
	uintptr(nDestPitch),
	uintptr(pSrcBits),
	uintptr(nSrcPitch),
	uintptr(bfidSrc),
	uintptr(prgbDestColors),
	uintptr(prgbSrcColors),
	uintptr(pbDestInvMap),
	uintptr(x),
	uintptr(y),
	uintptr(cx),
	uintptr(cy),
	uintptr(lDestTrans),
	uintptr(lSrcTrans),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function DitherTo8(
  pDestBits: Pointer;   // BYTE* in/out
  nDestPitch: Integer;   // INT
  pSrcBits: Pointer;   // BYTE* in/out
  nSrcPitch: Integer;   // INT
  bfidSrc: PGUID;   // GUID*
  prgbDestColors: Pointer;   // RGBQUAD* in/out
  prgbSrcColors: Pointer;   // RGBQUAD* in/out
  pbDestInvMap: Pointer;   // BYTE* in/out
  x: Integer;   // INT
  y: Integer;   // INT
  cx: Integer;   // INT
  cy: Integer;   // INT
  lDestTrans: Integer;   // INT
  lSrcTrans: Integer   // INT
): Integer; stdcall;
  external 'ImgUtil.dll' name 'DitherTo8';
result := DllCall("ImgUtil\DitherTo8"
    , "Ptr", pDestBits   ; BYTE* in/out
    , "Int", nDestPitch   ; INT
    , "Ptr", pSrcBits   ; BYTE* in/out
    , "Int", nSrcPitch   ; INT
    , "Ptr", bfidSrc   ; GUID*
    , "Ptr", prgbDestColors   ; RGBQUAD* in/out
    , "Ptr", prgbSrcColors   ; RGBQUAD* in/out
    , "Ptr", pbDestInvMap   ; BYTE* in/out
    , "Int", x   ; INT
    , "Int", y   ; INT
    , "Int", cx   ; INT
    , "Int", cy   ; INT
    , "Int", lDestTrans   ; INT
    , "Int", lSrcTrans   ; INT
    , "Int")   ; return: HRESULT
●DitherTo8(pDestBits, nDestPitch, pSrcBits, nSrcPitch, bfidSrc, prgbDestColors, prgbSrcColors, pbDestInvMap, x, y, cx, cy, lDestTrans, lSrcTrans) = DLL("ImgUtil.dll", "int DitherTo8(void*, int, void*, int, void*, void*, void*, void*, int, int, int, int, int, int)")
# 呼び出し: DitherTo8(pDestBits, nDestPitch, pSrcBits, nSrcPitch, bfidSrc, prgbDestColors, prgbSrcColors, pbDestInvMap, x, y, cx, cy, lDestTrans, lSrcTrans)
# pDestBits : BYTE* in/out -> "void*"
# nDestPitch : INT -> "int"
# pSrcBits : BYTE* in/out -> "void*"
# nSrcPitch : INT -> "int"
# bfidSrc : GUID* -> "void*"
# prgbDestColors : RGBQUAD* in/out -> "void*"
# prgbSrcColors : RGBQUAD* in/out -> "void*"
# pbDestInvMap : BYTE* in/out -> "void*"
# x : INT -> "int"
# y : INT -> "int"
# cx : INT -> "int"
# cy : INT -> "int"
# lDestTrans : INT -> "int"
# lSrcTrans : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。