ホーム › Graphics.GdiPlus › GdipMeasureDriverString
GdipMeasureDriverString
関数ドライバー文字列の境界矩形を測定する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipMeasureDriverString(
GpGraphics* graphics,
const WORD* text,
INT length,
const GpFont* font,
const PointF* positions,
INT flags,
const Matrix* matrix,
RectF* boundingBox
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| graphics | GpGraphics* | inout | 測定の基準とするGpGraphicsオブジェクトへのポインタ。 |
| text | WORD* | in | 測定するグリフインデックスまたは文字のWORD配列へのポインタ。 |
| length | INT | in | text配列の要素数を示すINT値。 |
| font | GpFont* | in | 測定に使用するGpFontオブジェクトへのポインタ。 |
| positions | PointF* | in | 各グリフの位置を示すPointF配列へのポインタ。 |
| flags | INT | in | 測定動作を制御するDriverStringOptionsフラグの組み合わせ。 |
| matrix | Matrix* | in | グリフに適用する変換行列Matrixへのポインタ。NULL可。 |
| boundingBox | RectF* | inout | 測定結果の外接矩形を受け取る出力先のRectFポインタ。 |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipMeasureDriverString(
GpGraphics* graphics,
const WORD* text,
INT length,
const GpFont* font,
const PointF* positions,
INT flags,
const Matrix* matrix,
RectF* boundingBox
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipMeasureDriverString(
IntPtr graphics, // GpGraphics* in/out
ref ushort text, // WORD*
int length, // INT
IntPtr font, // GpFont*
IntPtr positions, // PointF*
int flags, // INT
ref IntPtr matrix, // Matrix*
IntPtr boundingBox // RectF* in/out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipMeasureDriverString(
graphics As IntPtr, ' GpGraphics* in/out
ByRef text As UShort, ' WORD*
length As Integer, ' INT
font As IntPtr, ' GpFont*
positions As IntPtr, ' PointF*
flags As Integer, ' INT
ByRef matrix As IntPtr, ' Matrix*
boundingBox As IntPtr ' RectF* in/out
) As Integer
End Function' graphics : GpGraphics* in/out
' text : WORD*
' length : INT
' font : GpFont*
' positions : PointF*
' flags : INT
' matrix : Matrix*
' boundingBox : RectF* in/out
Declare PtrSafe Function GdipMeasureDriverString Lib "gdiplus" ( _
ByVal graphics As LongPtr, _
ByRef text As Integer, _
ByVal length As Long, _
ByVal font As LongPtr, _
ByVal positions As LongPtr, _
ByVal flags As Long, _
ByRef matrix As LongPtr, _
ByVal boundingBox As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdipMeasureDriverString = ctypes.windll.gdiplus.GdipMeasureDriverString
GdipMeasureDriverString.restype = ctypes.c_int
GdipMeasureDriverString.argtypes = [
ctypes.c_void_p, # graphics : GpGraphics* in/out
ctypes.POINTER(ctypes.c_ushort), # text : WORD*
ctypes.c_int, # length : INT
ctypes.c_void_p, # font : GpFont*
ctypes.c_void_p, # positions : PointF*
ctypes.c_int, # flags : INT
ctypes.c_void_p, # matrix : Matrix*
ctypes.c_void_p, # boundingBox : RectF* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipMeasureDriverString = Fiddle::Function.new(
lib['GdipMeasureDriverString'],
[
Fiddle::TYPE_VOIDP, # graphics : GpGraphics* in/out
Fiddle::TYPE_VOIDP, # text : WORD*
Fiddle::TYPE_INT, # length : INT
Fiddle::TYPE_VOIDP, # font : GpFont*
Fiddle::TYPE_VOIDP, # positions : PointF*
Fiddle::TYPE_INT, # flags : INT
Fiddle::TYPE_VOIDP, # matrix : Matrix*
Fiddle::TYPE_VOIDP, # boundingBox : RectF* in/out
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipMeasureDriverString(
graphics: *mut GpGraphics, // GpGraphics* in/out
text: *const u16, // WORD*
length: i32, // INT
font: *const GpFont, // GpFont*
positions: *const PointF, // PointF*
flags: i32, // INT
matrix: *const isize, // Matrix*
boundingBox: *mut RectF // RectF* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipMeasureDriverString(IntPtr graphics, ref ushort text, int length, IntPtr font, IntPtr positions, int flags, ref IntPtr matrix, IntPtr boundingBox);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipMeasureDriverString' -Namespace Win32 -PassThru
# $api::GdipMeasureDriverString(graphics, text, length, font, positions, flags, matrix, boundingBox)#uselib "gdiplus.dll"
#func global GdipMeasureDriverString "GdipMeasureDriverString" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GdipMeasureDriverString varptr(graphics), varptr(text), length, varptr(font), varptr(positions), flags, varptr(matrix), varptr(boundingBox) ; 戻り値は stat
; graphics : GpGraphics* in/out -> "sptr"
; text : WORD* -> "sptr"
; length : INT -> "sptr"
; font : GpFont* -> "sptr"
; positions : PointF* -> "sptr"
; flags : INT -> "sptr"
; matrix : Matrix* -> "sptr"
; boundingBox : RectF* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipMeasureDriverString "GdipMeasureDriverString" var, var, int, var, var, int, var, var ; res = GdipMeasureDriverString(graphics, text, length, font, positions, flags, matrix, boundingBox) ; graphics : GpGraphics* in/out -> "var" ; text : WORD* -> "var" ; length : INT -> "int" ; font : GpFont* -> "var" ; positions : PointF* -> "var" ; flags : INT -> "int" ; matrix : Matrix* -> "var" ; boundingBox : RectF* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipMeasureDriverString "GdipMeasureDriverString" sptr, sptr, int, sptr, sptr, int, sptr, sptr ; res = GdipMeasureDriverString(varptr(graphics), varptr(text), length, varptr(font), varptr(positions), flags, varptr(matrix), varptr(boundingBox)) ; graphics : GpGraphics* in/out -> "sptr" ; text : WORD* -> "sptr" ; length : INT -> "int" ; font : GpFont* -> "sptr" ; positions : PointF* -> "sptr" ; flags : INT -> "int" ; matrix : Matrix* -> "sptr" ; boundingBox : RectF* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipMeasureDriverString(GpGraphics* graphics, WORD* text, INT length, GpFont* font, PointF* positions, INT flags, Matrix* matrix, RectF* boundingBox) #uselib "gdiplus.dll" #cfunc global GdipMeasureDriverString "GdipMeasureDriverString" var, var, int, var, var, int, var, var ; res = GdipMeasureDriverString(graphics, text, length, font, positions, flags, matrix, boundingBox) ; graphics : GpGraphics* in/out -> "var" ; text : WORD* -> "var" ; length : INT -> "int" ; font : GpFont* -> "var" ; positions : PointF* -> "var" ; flags : INT -> "int" ; matrix : Matrix* -> "var" ; boundingBox : RectF* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipMeasureDriverString(GpGraphics* graphics, WORD* text, INT length, GpFont* font, PointF* positions, INT flags, Matrix* matrix, RectF* boundingBox) #uselib "gdiplus.dll" #cfunc global GdipMeasureDriverString "GdipMeasureDriverString" intptr, intptr, int, intptr, intptr, int, intptr, intptr ; res = GdipMeasureDriverString(varptr(graphics), varptr(text), length, varptr(font), varptr(positions), flags, varptr(matrix), varptr(boundingBox)) ; graphics : GpGraphics* in/out -> "intptr" ; text : WORD* -> "intptr" ; length : INT -> "int" ; font : GpFont* -> "intptr" ; positions : PointF* -> "intptr" ; flags : INT -> "int" ; matrix : Matrix* -> "intptr" ; boundingBox : RectF* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipMeasureDriverString = gdiplus.NewProc("GdipMeasureDriverString")
)
// graphics (GpGraphics* in/out), text (WORD*), length (INT), font (GpFont*), positions (PointF*), flags (INT), matrix (Matrix*), boundingBox (RectF* in/out)
r1, _, err := procGdipMeasureDriverString.Call(
uintptr(graphics),
uintptr(text),
uintptr(length),
uintptr(font),
uintptr(positions),
uintptr(flags),
uintptr(matrix),
uintptr(boundingBox),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Statusfunction GdipMeasureDriverString(
graphics: Pointer; // GpGraphics* in/out
text: Pointer; // WORD*
length: Integer; // INT
font: Pointer; // GpFont*
positions: Pointer; // PointF*
flags: Integer; // INT
matrix: Pointer; // Matrix*
boundingBox: Pointer // RectF* in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipMeasureDriverString';result := DllCall("gdiplus\GdipMeasureDriverString"
, "Ptr", graphics ; GpGraphics* in/out
, "Ptr", text ; WORD*
, "Int", length ; INT
, "Ptr", font ; GpFont*
, "Ptr", positions ; PointF*
, "Int", flags ; INT
, "Ptr", matrix ; Matrix*
, "Ptr", boundingBox ; RectF* in/out
, "Int") ; return: Status●GdipMeasureDriverString(graphics, text, length, font, positions, flags, matrix, boundingBox) = DLL("gdiplus.dll", "int GdipMeasureDriverString(void*, void*, int, void*, void*, int, void*, void*)")
# 呼び出し: GdipMeasureDriverString(graphics, text, length, font, positions, flags, matrix, boundingBox)
# graphics : GpGraphics* in/out -> "void*"
# text : WORD* -> "void*"
# length : INT -> "int"
# font : GpFont* -> "void*"
# positions : PointF* -> "void*"
# flags : INT -> "int"
# matrix : Matrix* -> "void*"
# boundingBox : RectF* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdiplus" fn GdipMeasureDriverString(
graphics: [*c]GpGraphics, // GpGraphics* in/out
text: [*c]u16, // WORD*
length: i32, // INT
font: [*c]GpFont, // GpFont*
positions: [*c]PointF, // PointF*
flags: i32, // INT
matrix: [*c]isize, // Matrix*
boundingBox: [*c]RectF // RectF* in/out
) callconv(std.os.windows.WINAPI) i32;proc GdipMeasureDriverString(
graphics: ptr GpGraphics, # GpGraphics* in/out
text: ptr uint16, # WORD*
length: int32, # INT
font: ptr GpFont, # GpFont*
positions: ptr PointF, # PointF*
flags: int32, # INT
matrix: ptr int, # Matrix*
boundingBox: ptr RectF # RectF* in/out
): int32 {.importc: "GdipMeasureDriverString", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipMeasureDriverString(
GpGraphics* graphics, // GpGraphics* in/out
ushort* text, // WORD*
int length, // INT
GpFont* font, // GpFont*
PointF* positions, // PointF*
int flags, // INT
ptrdiff_t* matrix, // Matrix*
RectF* boundingBox // RectF* in/out
);ccall((:GdipMeasureDriverString, "gdiplus.dll"), stdcall, Int32,
(Ptr{GpGraphics}, Ptr{UInt16}, Int32, Ptr{GpFont}, Ptr{PointF}, Int32, Ptr{Int}, Ptr{RectF}),
graphics, text, length, font, positions, flags, matrix, boundingBox)
# graphics : GpGraphics* in/out -> Ptr{GpGraphics}
# text : WORD* -> Ptr{UInt16}
# length : INT -> Int32
# font : GpFont* -> Ptr{GpFont}
# positions : PointF* -> Ptr{PointF}
# flags : INT -> Int32
# matrix : Matrix* -> Ptr{Int}
# boundingBox : RectF* in/out -> Ptr{RectF}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipMeasureDriverString(
void* graphics,
uint16_t* text,
int32_t length,
void* font,
void* positions,
int32_t flags,
intptr_t* matrix,
void* boundingBox);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipMeasureDriverString(graphics, text, length, font, positions, flags, matrix, boundingBox)
-- graphics : GpGraphics* in/out
-- text : WORD*
-- length : INT
-- font : GpFont*
-- positions : PointF*
-- flags : INT
-- matrix : Matrix*
-- boundingBox : RectF* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipMeasureDriverString = lib.func('__stdcall', 'GdipMeasureDriverString', 'int32_t', ['void *', 'uint16_t *', 'int32_t', 'void *', 'void *', 'int32_t', 'intptr_t *', 'void *']);
// GdipMeasureDriverString(graphics, text, length, font, positions, flags, matrix, boundingBox)
// graphics : GpGraphics* in/out -> 'void *'
// text : WORD* -> 'uint16_t *'
// length : INT -> 'int32_t'
// font : GpFont* -> 'void *'
// positions : PointF* -> 'void *'
// flags : INT -> 'int32_t'
// matrix : Matrix* -> 'intptr_t *'
// boundingBox : RectF* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipMeasureDriverString: { parameters: ["pointer", "pointer", "i32", "pointer", "pointer", "i32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GdipMeasureDriverString(graphics, text, length, font, positions, flags, matrix, boundingBox)
// graphics : GpGraphics* in/out -> "pointer"
// text : WORD* -> "pointer"
// length : INT -> "i32"
// font : GpFont* -> "pointer"
// positions : PointF* -> "pointer"
// flags : INT -> "i32"
// matrix : Matrix* -> "pointer"
// boundingBox : RectF* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipMeasureDriverString(
void* graphics,
uint16_t* text,
int32_t length,
void* font,
void* positions,
int32_t flags,
intptr_t* matrix,
void* boundingBox);
C, "gdiplus.dll");
// $ffi->GdipMeasureDriverString(graphics, text, length, font, positions, flags, matrix, boundingBox);
// graphics : GpGraphics* in/out
// text : WORD*
// length : INT
// font : GpFont*
// positions : PointF*
// flags : INT
// matrix : Matrix*
// boundingBox : RectF* in/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 GdipMeasureDriverString(
Pointer graphics, // GpGraphics* in/out
ShortByReference text, // WORD*
int length, // INT
Pointer font, // GpFont*
Pointer positions, // PointF*
int flags, // INT
LongByReference matrix, // Matrix*
Pointer boundingBox // RectF* in/out
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipMeasureDriverString = GdipMeasureDriverString(
graphics : GpGraphics*, # GpGraphics* in/out
text : UInt16*, # WORD*
length : Int32, # INT
font : GpFont*, # GpFont*
positions : PointF*, # PointF*
flags : Int32, # INT
matrix : LibC::SSizeT*, # Matrix*
boundingBox : RectF* # RectF* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GdipMeasureDriverStringNative = Int32 Function(Pointer<Void>, Pointer<Uint16>, Int32, Pointer<Void>, Pointer<Void>, Int32, Pointer<IntPtr>, Pointer<Void>);
typedef GdipMeasureDriverStringDart = int Function(Pointer<Void>, Pointer<Uint16>, int, Pointer<Void>, Pointer<Void>, int, Pointer<IntPtr>, Pointer<Void>);
final GdipMeasureDriverString = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipMeasureDriverStringNative, GdipMeasureDriverStringDart>('GdipMeasureDriverString');
// graphics : GpGraphics* in/out -> Pointer<Void>
// text : WORD* -> Pointer<Uint16>
// length : INT -> Int32
// font : GpFont* -> Pointer<Void>
// positions : PointF* -> Pointer<Void>
// flags : INT -> Int32
// matrix : Matrix* -> Pointer<IntPtr>
// boundingBox : RectF* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GdipMeasureDriverString(
graphics: Pointer; // GpGraphics* in/out
text: Pointer; // WORD*
length: Integer; // INT
font: Pointer; // GpFont*
positions: Pointer; // PointF*
flags: Integer; // INT
matrix: Pointer; // Matrix*
boundingBox: Pointer // RectF* in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipMeasureDriverString';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipMeasureDriverString"
c_GdipMeasureDriverString :: Ptr () -> Ptr Word16 -> Int32 -> Ptr () -> Ptr () -> Int32 -> Ptr CIntPtr -> Ptr () -> IO Int32
-- graphics : GpGraphics* in/out -> Ptr ()
-- text : WORD* -> Ptr Word16
-- length : INT -> Int32
-- font : GpFont* -> Ptr ()
-- positions : PointF* -> Ptr ()
-- flags : INT -> Int32
-- matrix : Matrix* -> Ptr CIntPtr
-- boundingBox : RectF* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipmeasuredriverstring =
foreign "GdipMeasureDriverString"
((ptr void) @-> (ptr uint16_t) @-> int32_t @-> (ptr void) @-> (ptr void) @-> int32_t @-> (ptr intptr_t) @-> (ptr void) @-> returning int32_t)
(* graphics : GpGraphics* in/out -> (ptr void) *)
(* text : WORD* -> (ptr uint16_t) *)
(* length : INT -> int32_t *)
(* font : GpFont* -> (ptr void) *)
(* positions : PointF* -> (ptr void) *)
(* flags : INT -> int32_t *)
(* matrix : Matrix* -> (ptr intptr_t) *)
(* boundingBox : RectF* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)
(cffi:defcfun ("GdipMeasureDriverString" gdip-measure-driver-string :convention :stdcall) :int32
(graphics :pointer) ; GpGraphics* in/out
(text :pointer) ; WORD*
(length :int32) ; INT
(font :pointer) ; GpFont*
(positions :pointer) ; PointF*
(flags :int32) ; INT
(matrix :pointer) ; Matrix*
(bounding-box :pointer)) ; RectF* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipMeasureDriverString = Win32::API::More->new('gdiplus',
'int GdipMeasureDriverString(LPVOID graphics, LPVOID text, int length, LPVOID font, LPVOID positions, int flags, LPVOID matrix, LPVOID boundingBox)');
# my $ret = $GdipMeasureDriverString->Call($graphics, $text, $length, $font, $positions, $flags, $matrix, $boundingBox);
# graphics : GpGraphics* in/out -> LPVOID
# text : WORD* -> LPVOID
# length : INT -> int
# font : GpFont* -> LPVOID
# positions : PointF* -> LPVOID
# flags : INT -> int
# matrix : Matrix* -> LPVOID
# boundingBox : RectF* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。