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