Win32 API 日本語リファレンス
ホームGraphics.GdiPlus › GdipGetImageWidth

GdipGetImageWidth

関数
イメージの幅をピクセル数で取得する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipGetImageWidth(
    GpImage* image,
    DWORD* width
);

パラメーター

名前方向
imageGpImage*inout
widthDWORD*inout

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipGetImageWidth(
    GpImage* image,
    DWORD* width
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipGetImageWidth(
    IntPtr image,   // GpImage* in/out
    ref uint width   // DWORD* in/out
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipGetImageWidth(
    image As IntPtr,   ' GpImage* in/out
    ByRef width As UInteger   ' DWORD* in/out
) As Integer
End Function
' image : GpImage* in/out
' width : DWORD* in/out
Declare PtrSafe Function GdipGetImageWidth Lib "gdiplus" ( _
    ByVal image As LongPtr, _
    ByRef width As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipGetImageWidth = ctypes.windll.gdiplus.GdipGetImageWidth
GdipGetImageWidth.restype = ctypes.c_int
GdipGetImageWidth.argtypes = [
    ctypes.c_void_p,  # image : GpImage* in/out
    ctypes.POINTER(wintypes.DWORD),  # width : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipGetImageWidth = Fiddle::Function.new(
  lib['GdipGetImageWidth'],
  [
    Fiddle::TYPE_VOIDP,  # image : GpImage* in/out
    Fiddle::TYPE_VOIDP,  # width : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipGetImageWidth(
        image: *mut GpImage,  // GpImage* in/out
        width: *mut u32  // DWORD* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipGetImageWidth(IntPtr image, ref uint width);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipGetImageWidth' -Namespace Win32 -PassThru
# $api::GdipGetImageWidth(image, width)
#uselib "gdiplus.dll"
#func global GdipGetImageWidth "GdipGetImageWidth" sptr, sptr
; GdipGetImageWidth varptr(image), varptr(width)   ; 戻り値は stat
; image : GpImage* in/out -> "sptr"
; width : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipGetImageWidth "GdipGetImageWidth" var, var
; res = GdipGetImageWidth(image, width)
; image : GpImage* in/out -> "var"
; width : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipGetImageWidth(GpImage* image, DWORD* width)
#uselib "gdiplus.dll"
#cfunc global GdipGetImageWidth "GdipGetImageWidth" var, var
; res = GdipGetImageWidth(image, width)
; image : GpImage* in/out -> "var"
; width : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipGetImageWidth = gdiplus.NewProc("GdipGetImageWidth")
)

// image (GpImage* in/out), width (DWORD* in/out)
r1, _, err := procGdipGetImageWidth.Call(
	uintptr(image),
	uintptr(width),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipGetImageWidth(
  image: Pointer;   // GpImage* in/out
  width: Pointer   // DWORD* in/out
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipGetImageWidth';
result := DllCall("gdiplus\GdipGetImageWidth"
    , "Ptr", image   ; GpImage* in/out
    , "Ptr", width   ; DWORD* in/out
    , "Int")   ; return: Status
●GdipGetImageWidth(image, width) = DLL("gdiplus.dll", "int GdipGetImageWidth(void*, void*)")
# 呼び出し: GdipGetImageWidth(image, width)
# image : GpImage* in/out -> "void*"
# width : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。