ホーム › Graphics.OpenGL › glReadPixels
glReadPixels
関数フレームバッファの矩形領域のピクセルを読み出す。
シグネチャ
// OPENGL32.dll
#include <windows.h>
void glReadPixels(
INT x,
INT y,
INT width,
INT height,
DWORD format,
DWORD type,
void* pixels
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| x | INT | in |
| y | INT | in |
| width | INT | in |
| height | INT | in |
| format | DWORD | in |
| type | DWORD | in |
| pixels | void* | inout |
戻り値の型: void
各言語での呼び出し定義
// OPENGL32.dll
#include <windows.h>
void glReadPixels(
INT x,
INT y,
INT width,
INT height,
DWORD format,
DWORD type,
void* pixels
);[DllImport("OPENGL32.dll", ExactSpelling = true)]
static extern void glReadPixels(
int x, // INT
int y, // INT
int width, // INT
int height, // INT
uint format, // DWORD
uint type, // DWORD
IntPtr pixels // void* in/out
);<DllImport("OPENGL32.dll", ExactSpelling:=True)>
Public Shared Sub glReadPixels(
x As Integer, ' INT
y As Integer, ' INT
width As Integer, ' INT
height As Integer, ' INT
format As UInteger, ' DWORD
type As UInteger, ' DWORD
pixels As IntPtr ' void* in/out
)
End Sub' x : INT
' y : INT
' width : INT
' height : INT
' format : DWORD
' type : DWORD
' pixels : void* in/out
Declare PtrSafe Sub glReadPixels Lib "opengl32" ( _
ByVal x As Long, _
ByVal y As Long, _
ByVal width As Long, _
ByVal height As Long, _
ByVal format As Long, _
ByVal type As Long, _
ByVal pixels As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
glReadPixels = ctypes.windll.opengl32.glReadPixels
glReadPixels.restype = None
glReadPixels.argtypes = [
ctypes.c_int, # x : INT
ctypes.c_int, # y : INT
ctypes.c_int, # width : INT
ctypes.c_int, # height : INT
wintypes.DWORD, # format : DWORD
wintypes.DWORD, # type : DWORD
ctypes.POINTER(None), # pixels : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OPENGL32.dll')
glReadPixels = Fiddle::Function.new(
lib['glReadPixels'],
[
Fiddle::TYPE_INT, # x : INT
Fiddle::TYPE_INT, # y : INT
Fiddle::TYPE_INT, # width : INT
Fiddle::TYPE_INT, # height : INT
-Fiddle::TYPE_INT, # format : DWORD
-Fiddle::TYPE_INT, # type : DWORD
Fiddle::TYPE_VOIDP, # pixels : void* in/out
],
Fiddle::TYPE_VOID)#[link(name = "opengl32")]
extern "system" {
fn glReadPixels(
x: i32, // INT
y: i32, // INT
width: i32, // INT
height: i32, // INT
format: u32, // DWORD
type: u32, // DWORD
pixels: *mut () // void* in/out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OPENGL32.dll")]
public static extern void glReadPixels(int x, int y, int width, int height, uint format, uint type, IntPtr pixels);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OPENGL32_glReadPixels' -Namespace Win32 -PassThru
# $api::glReadPixels(x, y, width, height, format, type, pixels)#uselib "OPENGL32.dll"
#func global glReadPixels "glReadPixels" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; glReadPixels x, y, width, height, format, type, pixels
; x : INT -> "sptr"
; y : INT -> "sptr"
; width : INT -> "sptr"
; height : INT -> "sptr"
; format : DWORD -> "sptr"
; type : DWORD -> "sptr"
; pixels : void* in/out -> "sptr"#uselib "OPENGL32.dll"
#func global glReadPixels "glReadPixels" int, int, int, int, int, int, sptr
; glReadPixels x, y, width, height, format, type, pixels
; x : INT -> "int"
; y : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
; format : DWORD -> "int"
; type : DWORD -> "int"
; pixels : void* in/out -> "sptr"; void glReadPixels(INT x, INT y, INT width, INT height, DWORD format, DWORD type, void* pixels)
#uselib "OPENGL32.dll"
#func global glReadPixels "glReadPixels" int, int, int, int, int, int, intptr
; glReadPixels x, y, width, height, format, type, pixels
; x : INT -> "int"
; y : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
; format : DWORD -> "int"
; type : DWORD -> "int"
; pixels : void* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
procglReadPixels = opengl32.NewProc("glReadPixels")
)
// x (INT), y (INT), width (INT), height (INT), format (DWORD), type (DWORD), pixels (void* in/out)
r1, _, err := procglReadPixels.Call(
uintptr(x),
uintptr(y),
uintptr(width),
uintptr(height),
uintptr(format),
uintptr(type),
uintptr(pixels),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure glReadPixels(
x: Integer; // INT
y: Integer; // INT
width: Integer; // INT
height: Integer; // INT
format: DWORD; // DWORD
type: DWORD; // DWORD
pixels: Pointer // void* in/out
); stdcall;
external 'OPENGL32.dll' name 'glReadPixels';result := DllCall("OPENGL32\glReadPixels"
, "Int", x ; INT
, "Int", y ; INT
, "Int", width ; INT
, "Int", height ; INT
, "UInt", format ; DWORD
, "UInt", type ; DWORD
, "Ptr", pixels ; void* in/out
, "Int") ; return: void●glReadPixels(x, y, width, height, format, type, pixels) = DLL("OPENGL32.dll", "int glReadPixels(int, int, int, int, dword, dword, void*)")
# 呼び出し: glReadPixels(x, y, width, height, format, type, pixels)
# x : INT -> "int"
# y : INT -> "int"
# width : INT -> "int"
# height : INT -> "int"
# format : DWORD -> "dword"
# type : DWORD -> "dword"
# pixels : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。