ホーム › Graphics.Gdi › StretchDIBits
StretchDIBits
関数DIBのピクセルを伸縮して転送先矩形へ転送する。
シグネチャ
// GDI32.dll
#include <windows.h>
INT StretchDIBits(
HDC hdc,
INT xDest,
INT yDest,
INT DestWidth,
INT DestHeight,
INT xSrc,
INT ySrc,
INT SrcWidth,
INT SrcHeight,
const void* lpBits, // optional
const BITMAPINFO* lpbmi,
DIB_USAGE iUsage,
ROP_CODE rop
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| xDest | INT | in |
| yDest | INT | in |
| DestWidth | INT | in |
| DestHeight | INT | in |
| xSrc | INT | in |
| ySrc | INT | in |
| SrcWidth | INT | in |
| SrcHeight | INT | in |
| lpBits | void* | inoptional |
| lpbmi | BITMAPINFO* | in |
| iUsage | DIB_USAGE | in |
| rop | ROP_CODE | in |
戻り値の型: INT
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
INT StretchDIBits(
HDC hdc,
INT xDest,
INT yDest,
INT DestWidth,
INT DestHeight,
INT xSrc,
INT ySrc,
INT SrcWidth,
INT SrcHeight,
const void* lpBits, // optional
const BITMAPINFO* lpbmi,
DIB_USAGE iUsage,
ROP_CODE rop
);[DllImport("GDI32.dll", ExactSpelling = true)]
static extern int StretchDIBits(
IntPtr hdc, // HDC
int xDest, // INT
int yDest, // INT
int DestWidth, // INT
int DestHeight, // INT
int xSrc, // INT
int ySrc, // INT
int SrcWidth, // INT
int SrcHeight, // INT
IntPtr lpBits, // void* optional
IntPtr lpbmi, // BITMAPINFO*
uint iUsage, // DIB_USAGE
uint rop // ROP_CODE
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function StretchDIBits(
hdc As IntPtr, ' HDC
xDest As Integer, ' INT
yDest As Integer, ' INT
DestWidth As Integer, ' INT
DestHeight As Integer, ' INT
xSrc As Integer, ' INT
ySrc As Integer, ' INT
SrcWidth As Integer, ' INT
SrcHeight As Integer, ' INT
lpBits As IntPtr, ' void* optional
lpbmi As IntPtr, ' BITMAPINFO*
iUsage As UInteger, ' DIB_USAGE
rop As UInteger ' ROP_CODE
) As Integer
End Function' hdc : HDC
' xDest : INT
' yDest : INT
' DestWidth : INT
' DestHeight : INT
' xSrc : INT
' ySrc : INT
' SrcWidth : INT
' SrcHeight : INT
' lpBits : void* optional
' lpbmi : BITMAPINFO*
' iUsage : DIB_USAGE
' rop : ROP_CODE
Declare PtrSafe Function StretchDIBits Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByVal xDest As Long, _
ByVal yDest As Long, _
ByVal DestWidth As Long, _
ByVal DestHeight As Long, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
ByVal SrcWidth As Long, _
ByVal SrcHeight As Long, _
ByVal lpBits As LongPtr, _
ByVal lpbmi As LongPtr, _
ByVal iUsage As Long, _
ByVal rop As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
StretchDIBits = ctypes.windll.gdi32.StretchDIBits
StretchDIBits.restype = ctypes.c_int
StretchDIBits.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_int, # xDest : INT
ctypes.c_int, # yDest : INT
ctypes.c_int, # DestWidth : INT
ctypes.c_int, # DestHeight : INT
ctypes.c_int, # xSrc : INT
ctypes.c_int, # ySrc : INT
ctypes.c_int, # SrcWidth : INT
ctypes.c_int, # SrcHeight : INT
ctypes.POINTER(None), # lpBits : void* optional
ctypes.c_void_p, # lpbmi : BITMAPINFO*
wintypes.DWORD, # iUsage : DIB_USAGE
wintypes.DWORD, # rop : ROP_CODE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
StretchDIBits = Fiddle::Function.new(
lib['StretchDIBits'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_INT, # xDest : INT
Fiddle::TYPE_INT, # yDest : INT
Fiddle::TYPE_INT, # DestWidth : INT
Fiddle::TYPE_INT, # DestHeight : INT
Fiddle::TYPE_INT, # xSrc : INT
Fiddle::TYPE_INT, # ySrc : INT
Fiddle::TYPE_INT, # SrcWidth : INT
Fiddle::TYPE_INT, # SrcHeight : INT
Fiddle::TYPE_VOIDP, # lpBits : void* optional
Fiddle::TYPE_VOIDP, # lpbmi : BITMAPINFO*
-Fiddle::TYPE_INT, # iUsage : DIB_USAGE
-Fiddle::TYPE_INT, # rop : ROP_CODE
],
Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn StretchDIBits(
hdc: *mut core::ffi::c_void, // HDC
xDest: i32, // INT
yDest: i32, // INT
DestWidth: i32, // INT
DestHeight: i32, // INT
xSrc: i32, // INT
ySrc: i32, // INT
SrcWidth: i32, // INT
SrcHeight: i32, // INT
lpBits: *const (), // void* optional
lpbmi: *const BITMAPINFO, // BITMAPINFO*
iUsage: u32, // DIB_USAGE
rop: u32 // ROP_CODE
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll")]
public static extern int StretchDIBits(IntPtr hdc, int xDest, int yDest, int DestWidth, int DestHeight, int xSrc, int ySrc, int SrcWidth, int SrcHeight, IntPtr lpBits, IntPtr lpbmi, uint iUsage, uint rop);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_StretchDIBits' -Namespace Win32 -PassThru
# $api::StretchDIBits(hdc, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight, lpBits, lpbmi, iUsage, rop)#uselib "GDI32.dll"
#func global StretchDIBits "StretchDIBits" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; StretchDIBits hdc, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight, lpBits, varptr(lpbmi), iUsage, rop ; 戻り値は stat
; hdc : HDC -> "sptr"
; xDest : INT -> "sptr"
; yDest : INT -> "sptr"
; DestWidth : INT -> "sptr"
; DestHeight : INT -> "sptr"
; xSrc : INT -> "sptr"
; ySrc : INT -> "sptr"
; SrcWidth : INT -> "sptr"
; SrcHeight : INT -> "sptr"
; lpBits : void* optional -> "sptr"
; lpbmi : BITMAPINFO* -> "sptr"
; iUsage : DIB_USAGE -> "sptr"
; rop : ROP_CODE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global StretchDIBits "StretchDIBits" sptr, int, int, int, int, int, int, int, int, sptr, var, int, int ; res = StretchDIBits(hdc, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight, lpBits, lpbmi, iUsage, rop) ; hdc : HDC -> "sptr" ; xDest : INT -> "int" ; yDest : INT -> "int" ; DestWidth : INT -> "int" ; DestHeight : INT -> "int" ; xSrc : INT -> "int" ; ySrc : INT -> "int" ; SrcWidth : INT -> "int" ; SrcHeight : INT -> "int" ; lpBits : void* optional -> "sptr" ; lpbmi : BITMAPINFO* -> "var" ; iUsage : DIB_USAGE -> "int" ; rop : ROP_CODE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global StretchDIBits "StretchDIBits" sptr, int, int, int, int, int, int, int, int, sptr, sptr, int, int ; res = StretchDIBits(hdc, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight, lpBits, varptr(lpbmi), iUsage, rop) ; hdc : HDC -> "sptr" ; xDest : INT -> "int" ; yDest : INT -> "int" ; DestWidth : INT -> "int" ; DestHeight : INT -> "int" ; xSrc : INT -> "int" ; ySrc : INT -> "int" ; SrcWidth : INT -> "int" ; SrcHeight : INT -> "int" ; lpBits : void* optional -> "sptr" ; lpbmi : BITMAPINFO* -> "sptr" ; iUsage : DIB_USAGE -> "int" ; rop : ROP_CODE -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT StretchDIBits(HDC hdc, INT xDest, INT yDest, INT DestWidth, INT DestHeight, INT xSrc, INT ySrc, INT SrcWidth, INT SrcHeight, void* lpBits, BITMAPINFO* lpbmi, DIB_USAGE iUsage, ROP_CODE rop) #uselib "GDI32.dll" #cfunc global StretchDIBits "StretchDIBits" intptr, int, int, int, int, int, int, int, int, intptr, var, int, int ; res = StretchDIBits(hdc, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight, lpBits, lpbmi, iUsage, rop) ; hdc : HDC -> "intptr" ; xDest : INT -> "int" ; yDest : INT -> "int" ; DestWidth : INT -> "int" ; DestHeight : INT -> "int" ; xSrc : INT -> "int" ; ySrc : INT -> "int" ; SrcWidth : INT -> "int" ; SrcHeight : INT -> "int" ; lpBits : void* optional -> "intptr" ; lpbmi : BITMAPINFO* -> "var" ; iUsage : DIB_USAGE -> "int" ; rop : ROP_CODE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT StretchDIBits(HDC hdc, INT xDest, INT yDest, INT DestWidth, INT DestHeight, INT xSrc, INT ySrc, INT SrcWidth, INT SrcHeight, void* lpBits, BITMAPINFO* lpbmi, DIB_USAGE iUsage, ROP_CODE rop) #uselib "GDI32.dll" #cfunc global StretchDIBits "StretchDIBits" intptr, int, int, int, int, int, int, int, int, intptr, intptr, int, int ; res = StretchDIBits(hdc, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight, lpBits, varptr(lpbmi), iUsage, rop) ; hdc : HDC -> "intptr" ; xDest : INT -> "int" ; yDest : INT -> "int" ; DestWidth : INT -> "int" ; DestHeight : INT -> "int" ; xSrc : INT -> "int" ; ySrc : INT -> "int" ; SrcWidth : INT -> "int" ; SrcHeight : INT -> "int" ; lpBits : void* optional -> "intptr" ; lpbmi : BITMAPINFO* -> "intptr" ; iUsage : DIB_USAGE -> "int" ; rop : ROP_CODE -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procStretchDIBits = gdi32.NewProc("StretchDIBits")
)
// hdc (HDC), xDest (INT), yDest (INT), DestWidth (INT), DestHeight (INT), xSrc (INT), ySrc (INT), SrcWidth (INT), SrcHeight (INT), lpBits (void* optional), lpbmi (BITMAPINFO*), iUsage (DIB_USAGE), rop (ROP_CODE)
r1, _, err := procStretchDIBits.Call(
uintptr(hdc),
uintptr(xDest),
uintptr(yDest),
uintptr(DestWidth),
uintptr(DestHeight),
uintptr(xSrc),
uintptr(ySrc),
uintptr(SrcWidth),
uintptr(SrcHeight),
uintptr(lpBits),
uintptr(lpbmi),
uintptr(iUsage),
uintptr(rop),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction StretchDIBits(
hdc: THandle; // HDC
xDest: Integer; // INT
yDest: Integer; // INT
DestWidth: Integer; // INT
DestHeight: Integer; // INT
xSrc: Integer; // INT
ySrc: Integer; // INT
SrcWidth: Integer; // INT
SrcHeight: Integer; // INT
lpBits: Pointer; // void* optional
lpbmi: Pointer; // BITMAPINFO*
iUsage: DWORD; // DIB_USAGE
rop: DWORD // ROP_CODE
): Integer; stdcall;
external 'GDI32.dll' name 'StretchDIBits';result := DllCall("GDI32\StretchDIBits"
, "Ptr", hdc ; HDC
, "Int", xDest ; INT
, "Int", yDest ; INT
, "Int", DestWidth ; INT
, "Int", DestHeight ; INT
, "Int", xSrc ; INT
, "Int", ySrc ; INT
, "Int", SrcWidth ; INT
, "Int", SrcHeight ; INT
, "Ptr", lpBits ; void* optional
, "Ptr", lpbmi ; BITMAPINFO*
, "UInt", iUsage ; DIB_USAGE
, "UInt", rop ; ROP_CODE
, "Int") ; return: INT●StretchDIBits(hdc, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight, lpBits, lpbmi, iUsage, rop) = DLL("GDI32.dll", "int StretchDIBits(void*, int, int, int, int, int, int, int, int, void*, void*, dword, dword)")
# 呼び出し: StretchDIBits(hdc, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight, lpBits, lpbmi, iUsage, rop)
# hdc : HDC -> "void*"
# xDest : INT -> "int"
# yDest : INT -> "int"
# DestWidth : INT -> "int"
# DestHeight : INT -> "int"
# xSrc : INT -> "int"
# ySrc : INT -> "int"
# SrcWidth : INT -> "int"
# SrcHeight : INT -> "int"
# lpBits : void* optional -> "void*"
# lpbmi : BITMAPINFO* -> "void*"
# iUsage : DIB_USAGE -> "dword"
# rop : ROP_CODE -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。