ホーム › UI.Controls › GetBufferedPaintBits
GetBufferedPaintBits
関数バッファのピクセルビット配列へのポインタを取得する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
HRESULT GetBufferedPaintBits(
INT_PTR hBufferedPaint,
RGBQUAD** ppbBuffer,
INT* pcxRow
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hBufferedPaint | INT_PTR | in | BeginBufferedPaint から取得した、バッファリングされた描画コンテキストのハンドルです。 |
| ppbBuffer | RGBQUAD** | out | この関数が返るときに、バッファビットマップのピクセルのアドレスへのポインターが格納されます。 |
| pcxRow | INT* | out | この関数が返るときに、バッファビットマップの幅 (ピクセル単位) へのポインターが格納されます。この値は必ずしもバッファの幅と等しいとは限らず、それより大きい場合があります。 |
戻り値の型: HRESULT
公式ドキュメント
バッファがデバイス非依存ビットマップ (DIB) である場合に、バッファビットマップへのポインターを取得します。
戻り値
種類: HRESULT
成功した場合は S_OK を、それ以外の場合はエラー値を返します。エラーが発生した場合、ppbBuffer には NULL が設定され、pcxRow には 0 が設定されます。
解説(Remarks)
1 ピクセルあたりのビット数は、BeginBufferedPaint に渡されたピクセル形式によって異なります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// UXTHEME.dll
#include <windows.h>
HRESULT GetBufferedPaintBits(
INT_PTR hBufferedPaint,
RGBQUAD** ppbBuffer,
INT* pcxRow
);[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern int GetBufferedPaintBits(
IntPtr hBufferedPaint, // INT_PTR
IntPtr ppbBuffer, // RGBQUAD** out
out int pcxRow // INT* out
);<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function GetBufferedPaintBits(
hBufferedPaint As IntPtr, ' INT_PTR
ppbBuffer As IntPtr, ' RGBQUAD** out
<Out> ByRef pcxRow As Integer ' INT* out
) As Integer
End Function' hBufferedPaint : INT_PTR
' ppbBuffer : RGBQUAD** out
' pcxRow : INT* out
Declare PtrSafe Function GetBufferedPaintBits Lib "uxtheme" ( _
ByVal hBufferedPaint As LongPtr, _
ByVal ppbBuffer As LongPtr, _
ByRef pcxRow As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetBufferedPaintBits = ctypes.windll.uxtheme.GetBufferedPaintBits
GetBufferedPaintBits.restype = ctypes.c_int
GetBufferedPaintBits.argtypes = [
ctypes.c_ssize_t, # hBufferedPaint : INT_PTR
ctypes.c_void_p, # ppbBuffer : RGBQUAD** out
ctypes.POINTER(ctypes.c_int), # pcxRow : INT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
GetBufferedPaintBits = Fiddle::Function.new(
lib['GetBufferedPaintBits'],
[
Fiddle::TYPE_INTPTR_T, # hBufferedPaint : INT_PTR
Fiddle::TYPE_VOIDP, # ppbBuffer : RGBQUAD** out
Fiddle::TYPE_VOIDP, # pcxRow : INT* out
],
Fiddle::TYPE_INT)#[link(name = "uxtheme")]
extern "system" {
fn GetBufferedPaintBits(
hBufferedPaint: isize, // INT_PTR
ppbBuffer: *mut *mut RGBQUAD, // RGBQUAD** out
pcxRow: *mut i32 // INT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int GetBufferedPaintBits(IntPtr hBufferedPaint, IntPtr ppbBuffer, out int pcxRow);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetBufferedPaintBits' -Namespace Win32 -PassThru
# $api::GetBufferedPaintBits(hBufferedPaint, ppbBuffer, pcxRow)#uselib "UXTHEME.dll"
#func global GetBufferedPaintBits "GetBufferedPaintBits" sptr, sptr, sptr
; GetBufferedPaintBits hBufferedPaint, varptr(ppbBuffer), varptr(pcxRow) ; 戻り値は stat
; hBufferedPaint : INT_PTR -> "sptr"
; ppbBuffer : RGBQUAD** out -> "sptr"
; pcxRow : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UXTHEME.dll" #cfunc global GetBufferedPaintBits "GetBufferedPaintBits" sptr, var, var ; res = GetBufferedPaintBits(hBufferedPaint, ppbBuffer, pcxRow) ; hBufferedPaint : INT_PTR -> "sptr" ; ppbBuffer : RGBQUAD** out -> "var" ; pcxRow : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UXTHEME.dll" #cfunc global GetBufferedPaintBits "GetBufferedPaintBits" sptr, sptr, sptr ; res = GetBufferedPaintBits(hBufferedPaint, varptr(ppbBuffer), varptr(pcxRow)) ; hBufferedPaint : INT_PTR -> "sptr" ; ppbBuffer : RGBQUAD** out -> "sptr" ; pcxRow : INT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetBufferedPaintBits(INT_PTR hBufferedPaint, RGBQUAD** ppbBuffer, INT* pcxRow) #uselib "UXTHEME.dll" #cfunc global GetBufferedPaintBits "GetBufferedPaintBits" intptr, var, var ; res = GetBufferedPaintBits(hBufferedPaint, ppbBuffer, pcxRow) ; hBufferedPaint : INT_PTR -> "intptr" ; ppbBuffer : RGBQUAD** out -> "var" ; pcxRow : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetBufferedPaintBits(INT_PTR hBufferedPaint, RGBQUAD** ppbBuffer, INT* pcxRow) #uselib "UXTHEME.dll" #cfunc global GetBufferedPaintBits "GetBufferedPaintBits" intptr, intptr, intptr ; res = GetBufferedPaintBits(hBufferedPaint, varptr(ppbBuffer), varptr(pcxRow)) ; hBufferedPaint : INT_PTR -> "intptr" ; ppbBuffer : RGBQUAD** out -> "intptr" ; pcxRow : INT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procGetBufferedPaintBits = uxtheme.NewProc("GetBufferedPaintBits")
)
// hBufferedPaint (INT_PTR), ppbBuffer (RGBQUAD** out), pcxRow (INT* out)
r1, _, err := procGetBufferedPaintBits.Call(
uintptr(hBufferedPaint),
uintptr(ppbBuffer),
uintptr(pcxRow),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetBufferedPaintBits(
hBufferedPaint: NativeInt; // INT_PTR
ppbBuffer: Pointer; // RGBQUAD** out
pcxRow: Pointer // INT* out
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetBufferedPaintBits';result := DllCall("UXTHEME\GetBufferedPaintBits"
, "Ptr", hBufferedPaint ; INT_PTR
, "Ptr", ppbBuffer ; RGBQUAD** out
, "Ptr", pcxRow ; INT* out
, "Int") ; return: HRESULT●GetBufferedPaintBits(hBufferedPaint, ppbBuffer, pcxRow) = DLL("UXTHEME.dll", "int GetBufferedPaintBits(int, void*, void*)")
# 呼び出し: GetBufferedPaintBits(hBufferedPaint, ppbBuffer, pcxRow)
# hBufferedPaint : INT_PTR -> "int"
# ppbBuffer : RGBQUAD** out -> "void*"
# pcxRow : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "uxtheme" fn GetBufferedPaintBits(
hBufferedPaint: isize, // INT_PTR
ppbBuffer: [*c][*c]RGBQUAD, // RGBQUAD** out
pcxRow: [*c]i32 // INT* out
) callconv(std.os.windows.WINAPI) i32;proc GetBufferedPaintBits(
hBufferedPaint: int, # INT_PTR
ppbBuffer: ptr RGBQUAD, # RGBQUAD** out
pcxRow: ptr int32 # INT* out
): int32 {.importc: "GetBufferedPaintBits", stdcall, dynlib: "UXTHEME.dll".}pragma(lib, "uxtheme");
extern(Windows)
int GetBufferedPaintBits(
ptrdiff_t hBufferedPaint, // INT_PTR
RGBQUAD** ppbBuffer, // RGBQUAD** out
int* pcxRow // INT* out
);ccall((:GetBufferedPaintBits, "UXTHEME.dll"), stdcall, Int32,
(Int, Ptr{RGBQUAD}, Ptr{Int32}),
hBufferedPaint, ppbBuffer, pcxRow)
# hBufferedPaint : INT_PTR -> Int
# ppbBuffer : RGBQUAD** out -> Ptr{RGBQUAD}
# pcxRow : INT* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetBufferedPaintBits(
intptr_t hBufferedPaint,
void* ppbBuffer,
int32_t* pcxRow);
]]
local uxtheme = ffi.load("uxtheme")
-- uxtheme.GetBufferedPaintBits(hBufferedPaint, ppbBuffer, pcxRow)
-- hBufferedPaint : INT_PTR
-- ppbBuffer : RGBQUAD** out
-- pcxRow : INT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('UXTHEME.dll');
const GetBufferedPaintBits = lib.func('__stdcall', 'GetBufferedPaintBits', 'int32_t', ['intptr_t', 'void *', 'int32_t *']);
// GetBufferedPaintBits(hBufferedPaint, ppbBuffer, pcxRow)
// hBufferedPaint : INT_PTR -> 'intptr_t'
// ppbBuffer : RGBQUAD** out -> 'void *'
// pcxRow : INT* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("UXTHEME.dll", {
GetBufferedPaintBits: { parameters: ["isize", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetBufferedPaintBits(hBufferedPaint, ppbBuffer, pcxRow)
// hBufferedPaint : INT_PTR -> "isize"
// ppbBuffer : RGBQUAD** out -> "pointer"
// pcxRow : INT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetBufferedPaintBits(
intptr_t hBufferedPaint,
void* ppbBuffer,
int32_t* pcxRow);
C, "UXTHEME.dll");
// $ffi->GetBufferedPaintBits(hBufferedPaint, ppbBuffer, pcxRow);
// hBufferedPaint : INT_PTR
// ppbBuffer : RGBQUAD** out
// pcxRow : INT* 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 Uxtheme extends StdCallLibrary {
Uxtheme INSTANCE = Native.load("uxtheme", Uxtheme.class);
int GetBufferedPaintBits(
long hBufferedPaint, // INT_PTR
Pointer ppbBuffer, // RGBQUAD** out
IntByReference pcxRow // INT* out
);
}@[Link("uxtheme")]
lib LibUXTHEME
fun GetBufferedPaintBits = GetBufferedPaintBits(
hBufferedPaint : LibC::SSizeT, # INT_PTR
ppbBuffer : RGBQUAD**, # RGBQUAD** out
pcxRow : Int32* # INT* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetBufferedPaintBitsNative = Int32 Function(IntPtr, Pointer<Void>, Pointer<Int32>);
typedef GetBufferedPaintBitsDart = int Function(int, Pointer<Void>, Pointer<Int32>);
final GetBufferedPaintBits = DynamicLibrary.open('UXTHEME.dll')
.lookupFunction<GetBufferedPaintBitsNative, GetBufferedPaintBitsDart>('GetBufferedPaintBits');
// hBufferedPaint : INT_PTR -> IntPtr
// ppbBuffer : RGBQUAD** out -> Pointer<Void>
// pcxRow : INT* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetBufferedPaintBits(
hBufferedPaint: NativeInt; // INT_PTR
ppbBuffer: Pointer; // RGBQUAD** out
pcxRow: Pointer // INT* out
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetBufferedPaintBits';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetBufferedPaintBits"
c_GetBufferedPaintBits :: CIntPtr -> Ptr () -> Ptr Int32 -> IO Int32
-- hBufferedPaint : INT_PTR -> CIntPtr
-- ppbBuffer : RGBQUAD** out -> Ptr ()
-- pcxRow : INT* out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getbufferedpaintbits =
foreign "GetBufferedPaintBits"
(intptr_t @-> (ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* hBufferedPaint : INT_PTR -> intptr_t *)
(* ppbBuffer : RGBQUAD** out -> (ptr void) *)
(* pcxRow : INT* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library uxtheme (t "UXTHEME.dll"))
(cffi:use-foreign-library uxtheme)
(cffi:defcfun ("GetBufferedPaintBits" get-buffered-paint-bits :convention :stdcall) :int32
(h-buffered-paint :int64) ; INT_PTR
(ppb-buffer :pointer) ; RGBQUAD** out
(pcx-row :pointer)) ; INT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetBufferedPaintBits = Win32::API::More->new('UXTHEME',
'int GetBufferedPaintBits(LPARAM hBufferedPaint, LPVOID ppbBuffer, LPVOID pcxRow)');
# my $ret = $GetBufferedPaintBits->Call($hBufferedPaint, $ppbBuffer, $pcxRow);
# hBufferedPaint : INT_PTR -> LPARAM
# ppbBuffer : RGBQUAD** out -> LPVOID
# pcxRow : INT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
使用する型