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

GdipScaleMatrix

関数
変換行列に拡大縮小を適用する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipScaleMatrix(
    Matrix* matrix,
    FLOAT scaleX,
    FLOAT scaleY,
    MatrixOrder order
);

パラメーター

名前方向説明
matrixMatrix*inout拡大縮小を適用する対象の行列へのポインタ。
scaleXFLOATinX方向の拡大縮小率。1.0で等倍、負値で反転する。
scaleYFLOATinY方向の拡大縮小率。1.0で等倍、負値で反転する。
orderMatrixOrderin拡大縮小を前乗算するか後乗算するかを指定する列挙値。

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipScaleMatrix(
    Matrix* matrix,
    FLOAT scaleX,
    FLOAT scaleY,
    MatrixOrder order
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipScaleMatrix(
    ref IntPtr matrix,   // Matrix* in/out
    float scaleX,   // FLOAT
    float scaleY,   // FLOAT
    int order   // MatrixOrder
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipScaleMatrix(
    ByRef matrix As IntPtr,   ' Matrix* in/out
    scaleX As Single,   ' FLOAT
    scaleY As Single,   ' FLOAT
    order As Integer   ' MatrixOrder
) As Integer
End Function
' matrix : Matrix* in/out
' scaleX : FLOAT
' scaleY : FLOAT
' order : MatrixOrder
Declare PtrSafe Function GdipScaleMatrix Lib "gdiplus" ( _
    ByRef matrix As LongPtr, _
    ByVal scaleX As Single, _
    ByVal scaleY As Single, _
    ByVal order As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipScaleMatrix = ctypes.windll.gdiplus.GdipScaleMatrix
GdipScaleMatrix.restype = ctypes.c_int
GdipScaleMatrix.argtypes = [
    ctypes.c_void_p,  # matrix : Matrix* in/out
    ctypes.c_float,  # scaleX : FLOAT
    ctypes.c_float,  # scaleY : FLOAT
    ctypes.c_int,  # order : MatrixOrder
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipScaleMatrix = gdiplus.NewProc("GdipScaleMatrix")
)

// matrix (Matrix* in/out), scaleX (FLOAT), scaleY (FLOAT), order (MatrixOrder)
r1, _, err := procGdipScaleMatrix.Call(
	uintptr(matrix),
	uintptr(math.Float32bits(scaleX)),
	uintptr(math.Float32bits(scaleY)),
	uintptr(order),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。
function GdipScaleMatrix(
  matrix: Pointer;   // Matrix* in/out
  scaleX: Single;   // FLOAT
  scaleY: Single;   // FLOAT
  order: Integer   // MatrixOrder
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipScaleMatrix';
result := DllCall("gdiplus\GdipScaleMatrix"
    , "Ptr", matrix   ; Matrix* in/out
    , "Float", scaleX   ; FLOAT
    , "Float", scaleY   ; FLOAT
    , "Int", order   ; MatrixOrder
    , "Int")   ; return: Status
●GdipScaleMatrix(matrix, scaleX, scaleY, order) = DLL("gdiplus.dll", "int GdipScaleMatrix(void*, float, float, int)")
# 呼び出し: GdipScaleMatrix(matrix, scaleX, scaleY, order)
# matrix : Matrix* in/out -> "void*"
# scaleX : FLOAT -> "float"
# scaleY : FLOAT -> "float"
# order : MatrixOrder -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "gdiplus" fn GdipScaleMatrix(
    matrix: [*c]isize, // Matrix* in/out
    scaleX: f32, // FLOAT
    scaleY: f32, // FLOAT
    order: i32 // MatrixOrder
) callconv(std.os.windows.WINAPI) i32;
proc GdipScaleMatrix(
    matrix: ptr int,  # Matrix* in/out
    scaleX: float32,  # FLOAT
    scaleY: float32,  # FLOAT
    order: int32  # MatrixOrder
): int32 {.importc: "GdipScaleMatrix", stdcall, dynlib: "gdiplus.dll".}
pragma(lib, "gdiplus");
extern(Windows)
int GdipScaleMatrix(
    ptrdiff_t* matrix,   // Matrix* in/out
    float scaleX,   // FLOAT
    float scaleY,   // FLOAT
    int order   // MatrixOrder
);
ccall((:GdipScaleMatrix, "gdiplus.dll"), stdcall, Int32,
      (Ptr{Int}, Float32, Float32, Int32),
      matrix, scaleX, scaleY, order)
# matrix : Matrix* in/out -> Ptr{Int}
# scaleX : FLOAT -> Float32
# scaleY : FLOAT -> Float32
# order : MatrixOrder -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GdipScaleMatrix(
    intptr_t* matrix,
    float scaleX,
    float scaleY,
    int32_t order);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipScaleMatrix(matrix, scaleX, scaleY, order)
-- matrix : Matrix* in/out
-- scaleX : FLOAT
-- scaleY : FLOAT
-- order : MatrixOrder
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipScaleMatrix = lib.func('__stdcall', 'GdipScaleMatrix', 'int32_t', ['intptr_t *', 'float', 'float', 'int32_t']);
// GdipScaleMatrix(matrix, scaleX, scaleY, order)
// matrix : Matrix* in/out -> 'intptr_t *'
// scaleX : FLOAT -> 'float'
// scaleY : FLOAT -> 'float'
// order : MatrixOrder -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("gdiplus.dll", {
  GdipScaleMatrix: { parameters: ["pointer", "f32", "f32", "i32"], result: "i32" },
});
// lib.symbols.GdipScaleMatrix(matrix, scaleX, scaleY, order)
// matrix : Matrix* in/out -> "pointer"
// scaleX : FLOAT -> "f32"
// scaleY : FLOAT -> "f32"
// order : MatrixOrder -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GdipScaleMatrix(
    intptr_t* matrix,
    float scaleX,
    float scaleY,
    int32_t order);
C, "gdiplus.dll");
// $ffi->GdipScaleMatrix(matrix, scaleX, scaleY, order);
// matrix : Matrix* in/out
// scaleX : FLOAT
// scaleY : FLOAT
// order : MatrixOrder
// 構造体/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 GdipScaleMatrix(
        LongByReference matrix,   // Matrix* in/out
        float scaleX,   // FLOAT
        float scaleY,   // FLOAT
        int order   // MatrixOrder
    );
}
@[Link("gdiplus")]
lib Libgdiplus
  fun GdipScaleMatrix = GdipScaleMatrix(
    matrix : LibC::SSizeT*,   # Matrix* in/out
    scaleX : Float32,   # FLOAT
    scaleY : Float32,   # FLOAT
    order : Int32   # MatrixOrder
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GdipScaleMatrixNative = Int32 Function(Pointer<IntPtr>, Float, Float, Int32);
typedef GdipScaleMatrixDart = int Function(Pointer<IntPtr>, double, double, int);
final GdipScaleMatrix = DynamicLibrary.open('gdiplus.dll')
    .lookupFunction<GdipScaleMatrixNative, GdipScaleMatrixDart>('GdipScaleMatrix');
// matrix : Matrix* in/out -> Pointer<IntPtr>
// scaleX : FLOAT -> Float
// scaleY : FLOAT -> Float
// order : MatrixOrder -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GdipScaleMatrix(
  matrix: Pointer;   // Matrix* in/out
  scaleX: Single;   // FLOAT
  scaleY: Single;   // FLOAT
  order: Integer   // MatrixOrder
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipScaleMatrix';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GdipScaleMatrix"
  c_GdipScaleMatrix :: Ptr CIntPtr -> CFloat -> CFloat -> Int32 -> IO Int32
-- matrix : Matrix* in/out -> Ptr CIntPtr
-- scaleX : FLOAT -> CFloat
-- scaleY : FLOAT -> CFloat
-- order : MatrixOrder -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let gdipscalematrix =
  foreign "GdipScaleMatrix"
    ((ptr intptr_t) @-> float @-> float @-> int32_t @-> returning int32_t)
(* matrix : Matrix* in/out -> (ptr intptr_t) *)
(* scaleX : FLOAT -> float *)
(* scaleY : FLOAT -> float *)
(* order : MatrixOrder -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)

(cffi:defcfun ("GdipScaleMatrix" gdip-scale-matrix :convention :stdcall) :int32
  (matrix :pointer)   ; Matrix* in/out
  (scale-x :float)   ; FLOAT
  (scale-y :float)   ; FLOAT
  (order :int32))   ; MatrixOrder
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GdipScaleMatrix = Win32::API::More->new('gdiplus',
    'int GdipScaleMatrix(LPVOID matrix, float scaleX, float scaleY, int order)');
# my $ret = $GdipScaleMatrix->Call($matrix, $scaleX, $scaleY, $order);
# matrix : Matrix* in/out -> LPVOID
# scaleX : FLOAT -> float
# scaleY : FLOAT -> float
# order : MatrixOrder -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型