ホーム › Graphics.GdiPlus › GdipBitmapGetHistogram
GdipBitmapGetHistogram
関数ビットマップの各チャンネルのヒストグラムデータを取得する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipBitmapGetHistogram(
GpBitmap* bitmap,
HistogramFormat format,
DWORD NumberOfEntries,
DWORD* channel0,
DWORD* channel1,
DWORD* channel2,
DWORD* channel3
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| bitmap | GpBitmap* | inout | ヒストグラムを取得する対象のGpBitmapオブジェクトへのポインタ。 |
| format | HistogramFormat | in | ヒストグラムのチャネル構成を示すHistogramFormat列挙値。 |
| NumberOfEntries | DWORD | in | 各チャネル配列の要素数。通常は256を指定する。 |
| channel0 | DWORD* | out | 第1チャネルの度数を受け取るDWORD配列へのポインタ。 |
| channel1 | DWORD* | out | 第2チャネルの度数を受け取るDWORD配列へのポインタ。未使用形式ではNULL可。 |
| channel2 | DWORD* | out | 第3チャネルの度数を受け取るDWORD配列へのポインタ。未使用形式ではNULL可。 |
| channel3 | DWORD* | out | 第4チャネル(アルファ等)の度数を受け取るDWORD配列へのポインタ。未使用ならNULL可。 |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipBitmapGetHistogram(
GpBitmap* bitmap,
HistogramFormat format,
DWORD NumberOfEntries,
DWORD* channel0,
DWORD* channel1,
DWORD* channel2,
DWORD* channel3
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipBitmapGetHistogram(
IntPtr bitmap, // GpBitmap* in/out
int format, // HistogramFormat
uint NumberOfEntries, // DWORD
out uint channel0, // DWORD* out
out uint channel1, // DWORD* out
out uint channel2, // DWORD* out
out uint channel3 // DWORD* out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipBitmapGetHistogram(
bitmap As IntPtr, ' GpBitmap* in/out
format As Integer, ' HistogramFormat
NumberOfEntries As UInteger, ' DWORD
<Out> ByRef channel0 As UInteger, ' DWORD* out
<Out> ByRef channel1 As UInteger, ' DWORD* out
<Out> ByRef channel2 As UInteger, ' DWORD* out
<Out> ByRef channel3 As UInteger ' DWORD* out
) As Integer
End Function' bitmap : GpBitmap* in/out
' format : HistogramFormat
' NumberOfEntries : DWORD
' channel0 : DWORD* out
' channel1 : DWORD* out
' channel2 : DWORD* out
' channel3 : DWORD* out
Declare PtrSafe Function GdipBitmapGetHistogram Lib "gdiplus" ( _
ByVal bitmap As LongPtr, _
ByVal format As Long, _
ByVal NumberOfEntries As Long, _
ByRef channel0 As Long, _
ByRef channel1 As Long, _
ByRef channel2 As Long, _
ByRef channel3 As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdipBitmapGetHistogram = ctypes.windll.gdiplus.GdipBitmapGetHistogram
GdipBitmapGetHistogram.restype = ctypes.c_int
GdipBitmapGetHistogram.argtypes = [
ctypes.c_void_p, # bitmap : GpBitmap* in/out
ctypes.c_int, # format : HistogramFormat
wintypes.DWORD, # NumberOfEntries : DWORD
ctypes.POINTER(wintypes.DWORD), # channel0 : DWORD* out
ctypes.POINTER(wintypes.DWORD), # channel1 : DWORD* out
ctypes.POINTER(wintypes.DWORD), # channel2 : DWORD* out
ctypes.POINTER(wintypes.DWORD), # channel3 : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipBitmapGetHistogram = Fiddle::Function.new(
lib['GdipBitmapGetHistogram'],
[
Fiddle::TYPE_VOIDP, # bitmap : GpBitmap* in/out
Fiddle::TYPE_INT, # format : HistogramFormat
-Fiddle::TYPE_INT, # NumberOfEntries : DWORD
Fiddle::TYPE_VOIDP, # channel0 : DWORD* out
Fiddle::TYPE_VOIDP, # channel1 : DWORD* out
Fiddle::TYPE_VOIDP, # channel2 : DWORD* out
Fiddle::TYPE_VOIDP, # channel3 : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipBitmapGetHistogram(
bitmap: *mut GpBitmap, // GpBitmap* in/out
format: i32, // HistogramFormat
NumberOfEntries: u32, // DWORD
channel0: *mut u32, // DWORD* out
channel1: *mut u32, // DWORD* out
channel2: *mut u32, // DWORD* out
channel3: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipBitmapGetHistogram(IntPtr bitmap, int format, uint NumberOfEntries, out uint channel0, out uint channel1, out uint channel2, out uint channel3);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipBitmapGetHistogram' -Namespace Win32 -PassThru
# $api::GdipBitmapGetHistogram(bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3)#uselib "gdiplus.dll"
#func global GdipBitmapGetHistogram "GdipBitmapGetHistogram" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GdipBitmapGetHistogram varptr(bitmap), format, NumberOfEntries, varptr(channel0), varptr(channel1), varptr(channel2), varptr(channel3) ; 戻り値は stat
; bitmap : GpBitmap* in/out -> "sptr"
; format : HistogramFormat -> "sptr"
; NumberOfEntries : DWORD -> "sptr"
; channel0 : DWORD* out -> "sptr"
; channel1 : DWORD* out -> "sptr"
; channel2 : DWORD* out -> "sptr"
; channel3 : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipBitmapGetHistogram "GdipBitmapGetHistogram" var, int, int, var, var, var, var ; res = GdipBitmapGetHistogram(bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3) ; bitmap : GpBitmap* in/out -> "var" ; format : HistogramFormat -> "int" ; NumberOfEntries : DWORD -> "int" ; channel0 : DWORD* out -> "var" ; channel1 : DWORD* out -> "var" ; channel2 : DWORD* out -> "var" ; channel3 : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipBitmapGetHistogram "GdipBitmapGetHistogram" sptr, int, int, sptr, sptr, sptr, sptr ; res = GdipBitmapGetHistogram(varptr(bitmap), format, NumberOfEntries, varptr(channel0), varptr(channel1), varptr(channel2), varptr(channel3)) ; bitmap : GpBitmap* in/out -> "sptr" ; format : HistogramFormat -> "int" ; NumberOfEntries : DWORD -> "int" ; channel0 : DWORD* out -> "sptr" ; channel1 : DWORD* out -> "sptr" ; channel2 : DWORD* out -> "sptr" ; channel3 : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipBitmapGetHistogram(GpBitmap* bitmap, HistogramFormat format, DWORD NumberOfEntries, DWORD* channel0, DWORD* channel1, DWORD* channel2, DWORD* channel3) #uselib "gdiplus.dll" #cfunc global GdipBitmapGetHistogram "GdipBitmapGetHistogram" var, int, int, var, var, var, var ; res = GdipBitmapGetHistogram(bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3) ; bitmap : GpBitmap* in/out -> "var" ; format : HistogramFormat -> "int" ; NumberOfEntries : DWORD -> "int" ; channel0 : DWORD* out -> "var" ; channel1 : DWORD* out -> "var" ; channel2 : DWORD* out -> "var" ; channel3 : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipBitmapGetHistogram(GpBitmap* bitmap, HistogramFormat format, DWORD NumberOfEntries, DWORD* channel0, DWORD* channel1, DWORD* channel2, DWORD* channel3) #uselib "gdiplus.dll" #cfunc global GdipBitmapGetHistogram "GdipBitmapGetHistogram" intptr, int, int, intptr, intptr, intptr, intptr ; res = GdipBitmapGetHistogram(varptr(bitmap), format, NumberOfEntries, varptr(channel0), varptr(channel1), varptr(channel2), varptr(channel3)) ; bitmap : GpBitmap* in/out -> "intptr" ; format : HistogramFormat -> "int" ; NumberOfEntries : DWORD -> "int" ; channel0 : DWORD* out -> "intptr" ; channel1 : DWORD* out -> "intptr" ; channel2 : DWORD* out -> "intptr" ; channel3 : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipBitmapGetHistogram = gdiplus.NewProc("GdipBitmapGetHistogram")
)
// bitmap (GpBitmap* in/out), format (HistogramFormat), NumberOfEntries (DWORD), channel0 (DWORD* out), channel1 (DWORD* out), channel2 (DWORD* out), channel3 (DWORD* out)
r1, _, err := procGdipBitmapGetHistogram.Call(
uintptr(bitmap),
uintptr(format),
uintptr(NumberOfEntries),
uintptr(channel0),
uintptr(channel1),
uintptr(channel2),
uintptr(channel3),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Statusfunction GdipBitmapGetHistogram(
bitmap: Pointer; // GpBitmap* in/out
format: Integer; // HistogramFormat
NumberOfEntries: DWORD; // DWORD
channel0: Pointer; // DWORD* out
channel1: Pointer; // DWORD* out
channel2: Pointer; // DWORD* out
channel3: Pointer // DWORD* out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipBitmapGetHistogram';result := DllCall("gdiplus\GdipBitmapGetHistogram"
, "Ptr", bitmap ; GpBitmap* in/out
, "Int", format ; HistogramFormat
, "UInt", NumberOfEntries ; DWORD
, "Ptr", channel0 ; DWORD* out
, "Ptr", channel1 ; DWORD* out
, "Ptr", channel2 ; DWORD* out
, "Ptr", channel3 ; DWORD* out
, "Int") ; return: Status●GdipBitmapGetHistogram(bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3) = DLL("gdiplus.dll", "int GdipBitmapGetHistogram(void*, int, dword, void*, void*, void*, void*)")
# 呼び出し: GdipBitmapGetHistogram(bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3)
# bitmap : GpBitmap* in/out -> "void*"
# format : HistogramFormat -> "int"
# NumberOfEntries : DWORD -> "dword"
# channel0 : DWORD* out -> "void*"
# channel1 : DWORD* out -> "void*"
# channel2 : DWORD* out -> "void*"
# channel3 : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdiplus" fn GdipBitmapGetHistogram(
bitmap: [*c]GpBitmap, // GpBitmap* in/out
format: i32, // HistogramFormat
NumberOfEntries: u32, // DWORD
channel0: [*c]u32, // DWORD* out
channel1: [*c]u32, // DWORD* out
channel2: [*c]u32, // DWORD* out
channel3: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;proc GdipBitmapGetHistogram(
bitmap: ptr GpBitmap, # GpBitmap* in/out
format: int32, # HistogramFormat
NumberOfEntries: uint32, # DWORD
channel0: ptr uint32, # DWORD* out
channel1: ptr uint32, # DWORD* out
channel2: ptr uint32, # DWORD* out
channel3: ptr uint32 # DWORD* out
): int32 {.importc: "GdipBitmapGetHistogram", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipBitmapGetHistogram(
GpBitmap* bitmap, // GpBitmap* in/out
int format, // HistogramFormat
uint NumberOfEntries, // DWORD
uint* channel0, // DWORD* out
uint* channel1, // DWORD* out
uint* channel2, // DWORD* out
uint* channel3 // DWORD* out
);ccall((:GdipBitmapGetHistogram, "gdiplus.dll"), stdcall, Int32,
(Ptr{GpBitmap}, Int32, UInt32, Ptr{UInt32}, Ptr{UInt32}, Ptr{UInt32}, Ptr{UInt32}),
bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3)
# bitmap : GpBitmap* in/out -> Ptr{GpBitmap}
# format : HistogramFormat -> Int32
# NumberOfEntries : DWORD -> UInt32
# channel0 : DWORD* out -> Ptr{UInt32}
# channel1 : DWORD* out -> Ptr{UInt32}
# channel2 : DWORD* out -> Ptr{UInt32}
# channel3 : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipBitmapGetHistogram(
void* bitmap,
int32_t format,
uint32_t NumberOfEntries,
uint32_t* channel0,
uint32_t* channel1,
uint32_t* channel2,
uint32_t* channel3);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipBitmapGetHistogram(bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3)
-- bitmap : GpBitmap* in/out
-- format : HistogramFormat
-- NumberOfEntries : DWORD
-- channel0 : DWORD* out
-- channel1 : DWORD* out
-- channel2 : DWORD* out
-- channel3 : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipBitmapGetHistogram = lib.func('__stdcall', 'GdipBitmapGetHistogram', 'int32_t', ['void *', 'int32_t', 'uint32_t', 'uint32_t *', 'uint32_t *', 'uint32_t *', 'uint32_t *']);
// GdipBitmapGetHistogram(bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3)
// bitmap : GpBitmap* in/out -> 'void *'
// format : HistogramFormat -> 'int32_t'
// NumberOfEntries : DWORD -> 'uint32_t'
// channel0 : DWORD* out -> 'uint32_t *'
// channel1 : DWORD* out -> 'uint32_t *'
// channel2 : DWORD* out -> 'uint32_t *'
// channel3 : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipBitmapGetHistogram: { parameters: ["pointer", "i32", "u32", "pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GdipBitmapGetHistogram(bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3)
// bitmap : GpBitmap* in/out -> "pointer"
// format : HistogramFormat -> "i32"
// NumberOfEntries : DWORD -> "u32"
// channel0 : DWORD* out -> "pointer"
// channel1 : DWORD* out -> "pointer"
// channel2 : DWORD* out -> "pointer"
// channel3 : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipBitmapGetHistogram(
void* bitmap,
int32_t format,
uint32_t NumberOfEntries,
uint32_t* channel0,
uint32_t* channel1,
uint32_t* channel2,
uint32_t* channel3);
C, "gdiplus.dll");
// $ffi->GdipBitmapGetHistogram(bitmap, format, NumberOfEntries, channel0, channel1, channel2, channel3);
// bitmap : GpBitmap* in/out
// format : HistogramFormat
// NumberOfEntries : DWORD
// channel0 : DWORD* out
// channel1 : DWORD* out
// channel2 : DWORD* out
// channel3 : DWORD* 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 Gdiplus extends StdCallLibrary {
Gdiplus INSTANCE = Native.load("gdiplus", Gdiplus.class);
int GdipBitmapGetHistogram(
Pointer bitmap, // GpBitmap* in/out
int format, // HistogramFormat
int NumberOfEntries, // DWORD
IntByReference channel0, // DWORD* out
IntByReference channel1, // DWORD* out
IntByReference channel2, // DWORD* out
IntByReference channel3 // DWORD* out
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipBitmapGetHistogram = GdipBitmapGetHistogram(
bitmap : GpBitmap*, # GpBitmap* in/out
format : Int32, # HistogramFormat
NumberOfEntries : UInt32, # DWORD
channel0 : UInt32*, # DWORD* out
channel1 : UInt32*, # DWORD* out
channel2 : UInt32*, # DWORD* out
channel3 : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GdipBitmapGetHistogramNative = Int32 Function(Pointer<Void>, Int32, Uint32, Pointer<Uint32>, Pointer<Uint32>, Pointer<Uint32>, Pointer<Uint32>);
typedef GdipBitmapGetHistogramDart = int Function(Pointer<Void>, int, int, Pointer<Uint32>, Pointer<Uint32>, Pointer<Uint32>, Pointer<Uint32>);
final GdipBitmapGetHistogram = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipBitmapGetHistogramNative, GdipBitmapGetHistogramDart>('GdipBitmapGetHistogram');
// bitmap : GpBitmap* in/out -> Pointer<Void>
// format : HistogramFormat -> Int32
// NumberOfEntries : DWORD -> Uint32
// channel0 : DWORD* out -> Pointer<Uint32>
// channel1 : DWORD* out -> Pointer<Uint32>
// channel2 : DWORD* out -> Pointer<Uint32>
// channel3 : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GdipBitmapGetHistogram(
bitmap: Pointer; // GpBitmap* in/out
format: Integer; // HistogramFormat
NumberOfEntries: DWORD; // DWORD
channel0: Pointer; // DWORD* out
channel1: Pointer; // DWORD* out
channel2: Pointer; // DWORD* out
channel3: Pointer // DWORD* out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipBitmapGetHistogram';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipBitmapGetHistogram"
c_GdipBitmapGetHistogram :: Ptr () -> Int32 -> Word32 -> Ptr Word32 -> Ptr Word32 -> Ptr Word32 -> Ptr Word32 -> IO Int32
-- bitmap : GpBitmap* in/out -> Ptr ()
-- format : HistogramFormat -> Int32
-- NumberOfEntries : DWORD -> Word32
-- channel0 : DWORD* out -> Ptr Word32
-- channel1 : DWORD* out -> Ptr Word32
-- channel2 : DWORD* out -> Ptr Word32
-- channel3 : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipbitmapgethistogram =
foreign "GdipBitmapGetHistogram"
((ptr void) @-> int32_t @-> uint32_t @-> (ptr uint32_t) @-> (ptr uint32_t) @-> (ptr uint32_t) @-> (ptr uint32_t) @-> returning int32_t)
(* bitmap : GpBitmap* in/out -> (ptr void) *)
(* format : HistogramFormat -> int32_t *)
(* NumberOfEntries : DWORD -> uint32_t *)
(* channel0 : DWORD* out -> (ptr uint32_t) *)
(* channel1 : DWORD* out -> (ptr uint32_t) *)
(* channel2 : DWORD* out -> (ptr uint32_t) *)
(* channel3 : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)
(cffi:defcfun ("GdipBitmapGetHistogram" gdip-bitmap-get-histogram :convention :stdcall) :int32
(bitmap :pointer) ; GpBitmap* in/out
(format :int32) ; HistogramFormat
(number-of-entries :uint32) ; DWORD
(channel0 :pointer) ; DWORD* out
(channel1 :pointer) ; DWORD* out
(channel2 :pointer) ; DWORD* out
(channel3 :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipBitmapGetHistogram = Win32::API::More->new('gdiplus',
'int GdipBitmapGetHistogram(LPVOID bitmap, int format, DWORD NumberOfEntries, LPVOID channel0, LPVOID channel1, LPVOID channel2, LPVOID channel3)');
# my $ret = $GdipBitmapGetHistogram->Call($bitmap, $format, $NumberOfEntries, $channel0, $channel1, $channel2, $channel3);
# bitmap : GpBitmap* in/out -> LPVOID
# format : HistogramFormat -> int
# NumberOfEntries : DWORD -> DWORD
# channel0 : DWORD* out -> LPVOID
# channel1 : DWORD* out -> LPVOID
# channel2 : DWORD* out -> LPVOID
# channel3 : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。