ホーム › Graphics.OpenGL › gluScaleImage
gluScaleImage
関数画像データを指定サイズへ拡大縮小して変換する。
シグネチャ
// GLU32.dll
#include <windows.h>
INT gluScaleImage(
DWORD format,
INT widthin,
INT heightin,
DWORD typein,
const void* datain,
INT widthout,
INT heightout,
DWORD typeout,
void* dataout
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| format | DWORD | in | 入出力ピクセルの色形式。GL_RGBAなど。 |
| widthin | INT | in | 入力画像の幅(ピクセル)。 |
| heightin | INT | in | 入力画像の高さ(ピクセル)。 |
| typein | DWORD | in | 入力ピクセルデータの型。GL_UNSIGNED_BYTEなど。 |
| datain | void* | in | 入力画像データへのポインタ。 |
| widthout | INT | in | 出力画像の幅(ピクセル)。 |
| heightout | INT | in | 出力画像の高さ(ピクセル)。 |
| typeout | DWORD | in | 出力ピクセルデータの型。 |
| dataout | void* | inout | 拡大縮小結果を書き込む出力バッファへのポインタ。 |
戻り値の型: INT
各言語での呼び出し定義
// GLU32.dll
#include <windows.h>
INT gluScaleImage(
DWORD format,
INT widthin,
INT heightin,
DWORD typein,
const void* datain,
INT widthout,
INT heightout,
DWORD typeout,
void* dataout
);[DllImport("GLU32.dll", ExactSpelling = true)]
static extern int gluScaleImage(
uint format, // DWORD
int widthin, // INT
int heightin, // INT
uint typein, // DWORD
IntPtr datain, // void*
int widthout, // INT
int heightout, // INT
uint typeout, // DWORD
IntPtr dataout // void* in/out
);<DllImport("GLU32.dll", ExactSpelling:=True)>
Public Shared Function gluScaleImage(
format As UInteger, ' DWORD
widthin As Integer, ' INT
heightin As Integer, ' INT
typein As UInteger, ' DWORD
datain As IntPtr, ' void*
widthout As Integer, ' INT
heightout As Integer, ' INT
typeout As UInteger, ' DWORD
dataout As IntPtr ' void* in/out
) As Integer
End Function' format : DWORD
' widthin : INT
' heightin : INT
' typein : DWORD
' datain : void*
' widthout : INT
' heightout : INT
' typeout : DWORD
' dataout : void* in/out
Declare PtrSafe Function gluScaleImage Lib "glu32" ( _
ByVal format As Long, _
ByVal widthin As Long, _
ByVal heightin As Long, _
ByVal typein As Long, _
ByVal datain As LongPtr, _
ByVal widthout As Long, _
ByVal heightout As Long, _
ByVal typeout As Long, _
ByVal dataout As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
gluScaleImage = ctypes.windll.glu32.gluScaleImage
gluScaleImage.restype = ctypes.c_int
gluScaleImage.argtypes = [
wintypes.DWORD, # format : DWORD
ctypes.c_int, # widthin : INT
ctypes.c_int, # heightin : INT
wintypes.DWORD, # typein : DWORD
ctypes.POINTER(None), # datain : void*
ctypes.c_int, # widthout : INT
ctypes.c_int, # heightout : INT
wintypes.DWORD, # typeout : DWORD
ctypes.POINTER(None), # dataout : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GLU32.dll')
gluScaleImage = Fiddle::Function.new(
lib['gluScaleImage'],
[
-Fiddle::TYPE_INT, # format : DWORD
Fiddle::TYPE_INT, # widthin : INT
Fiddle::TYPE_INT, # heightin : INT
-Fiddle::TYPE_INT, # typein : DWORD
Fiddle::TYPE_VOIDP, # datain : void*
Fiddle::TYPE_INT, # widthout : INT
Fiddle::TYPE_INT, # heightout : INT
-Fiddle::TYPE_INT, # typeout : DWORD
Fiddle::TYPE_VOIDP, # dataout : void* in/out
],
Fiddle::TYPE_INT)#[link(name = "glu32")]
extern "system" {
fn gluScaleImage(
format: u32, // DWORD
widthin: i32, // INT
heightin: i32, // INT
typein: u32, // DWORD
datain: *const (), // void*
widthout: i32, // INT
heightout: i32, // INT
typeout: u32, // DWORD
dataout: *mut () // void* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GLU32.dll")]
public static extern int gluScaleImage(uint format, int widthin, int heightin, uint typein, IntPtr datain, int widthout, int heightout, uint typeout, IntPtr dataout);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GLU32_gluScaleImage' -Namespace Win32 -PassThru
# $api::gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout)#uselib "GLU32.dll"
#func global gluScaleImage "gluScaleImage" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; gluScaleImage format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout ; 戻り値は stat
; format : DWORD -> "sptr"
; widthin : INT -> "sptr"
; heightin : INT -> "sptr"
; typein : DWORD -> "sptr"
; datain : void* -> "sptr"
; widthout : INT -> "sptr"
; heightout : INT -> "sptr"
; typeout : DWORD -> "sptr"
; dataout : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "GLU32.dll"
#cfunc global gluScaleImage "gluScaleImage" int, int, int, int, sptr, int, int, int, sptr
; res = gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout)
; format : DWORD -> "int"
; widthin : INT -> "int"
; heightin : INT -> "int"
; typein : DWORD -> "int"
; datain : void* -> "sptr"
; widthout : INT -> "int"
; heightout : INT -> "int"
; typeout : DWORD -> "int"
; dataout : void* in/out -> "sptr"; INT gluScaleImage(DWORD format, INT widthin, INT heightin, DWORD typein, void* datain, INT widthout, INT heightout, DWORD typeout, void* dataout)
#uselib "GLU32.dll"
#cfunc global gluScaleImage "gluScaleImage" int, int, int, int, intptr, int, int, int, intptr
; res = gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout)
; format : DWORD -> "int"
; widthin : INT -> "int"
; heightin : INT -> "int"
; typein : DWORD -> "int"
; datain : void* -> "intptr"
; widthout : INT -> "int"
; heightout : INT -> "int"
; typeout : DWORD -> "int"
; dataout : void* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
glu32 = windows.NewLazySystemDLL("GLU32.dll")
procgluScaleImage = glu32.NewProc("gluScaleImage")
)
// format (DWORD), widthin (INT), heightin (INT), typein (DWORD), datain (void*), widthout (INT), heightout (INT), typeout (DWORD), dataout (void* in/out)
r1, _, err := procgluScaleImage.Call(
uintptr(format),
uintptr(widthin),
uintptr(heightin),
uintptr(typein),
uintptr(datain),
uintptr(widthout),
uintptr(heightout),
uintptr(typeout),
uintptr(dataout),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction gluScaleImage(
format: DWORD; // DWORD
widthin: Integer; // INT
heightin: Integer; // INT
typein: DWORD; // DWORD
datain: Pointer; // void*
widthout: Integer; // INT
heightout: Integer; // INT
typeout: DWORD; // DWORD
dataout: Pointer // void* in/out
): Integer; stdcall;
external 'GLU32.dll' name 'gluScaleImage';result := DllCall("GLU32\gluScaleImage"
, "UInt", format ; DWORD
, "Int", widthin ; INT
, "Int", heightin ; INT
, "UInt", typein ; DWORD
, "Ptr", datain ; void*
, "Int", widthout ; INT
, "Int", heightout ; INT
, "UInt", typeout ; DWORD
, "Ptr", dataout ; void* in/out
, "Int") ; return: INT●gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout) = DLL("GLU32.dll", "int gluScaleImage(dword, int, int, dword, void*, int, int, dword, void*)")
# 呼び出し: gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout)
# format : DWORD -> "dword"
# widthin : INT -> "int"
# heightin : INT -> "int"
# typein : DWORD -> "dword"
# datain : void* -> "void*"
# widthout : INT -> "int"
# heightout : INT -> "int"
# typeout : DWORD -> "dword"
# dataout : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "glu32" fn gluScaleImage(
format: u32, // DWORD
widthin: i32, // INT
heightin: i32, // INT
typein: u32, // DWORD
datain: ?*anyopaque, // void*
widthout: i32, // INT
heightout: i32, // INT
typeout: u32, // DWORD
dataout: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;proc gluScaleImage(
format: uint32, # DWORD
widthin: int32, # INT
heightin: int32, # INT
typein: uint32, # DWORD
datain: pointer, # void*
widthout: int32, # INT
heightout: int32, # INT
typeout: uint32, # DWORD
dataout: pointer # void* in/out
): int32 {.importc: "gluScaleImage", stdcall, dynlib: "GLU32.dll".}pragma(lib, "glu32");
extern(Windows)
int gluScaleImage(
uint format, // DWORD
int widthin, // INT
int heightin, // INT
uint typein, // DWORD
void* datain, // void*
int widthout, // INT
int heightout, // INT
uint typeout, // DWORD
void* dataout // void* in/out
);ccall((:gluScaleImage, "GLU32.dll"), stdcall, Int32,
(UInt32, Int32, Int32, UInt32, Ptr{Cvoid}, Int32, Int32, UInt32, Ptr{Cvoid}),
format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout)
# format : DWORD -> UInt32
# widthin : INT -> Int32
# heightin : INT -> Int32
# typein : DWORD -> UInt32
# datain : void* -> Ptr{Cvoid}
# widthout : INT -> Int32
# heightout : INT -> Int32
# typeout : DWORD -> UInt32
# dataout : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t gluScaleImage(
uint32_t format,
int32_t widthin,
int32_t heightin,
uint32_t typein,
void* datain,
int32_t widthout,
int32_t heightout,
uint32_t typeout,
void* dataout);
]]
local glu32 = ffi.load("glu32")
-- glu32.gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout)
-- format : DWORD
-- widthin : INT
-- heightin : INT
-- typein : DWORD
-- datain : void*
-- widthout : INT
-- heightout : INT
-- typeout : DWORD
-- dataout : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GLU32.dll');
const gluScaleImage = lib.func('__stdcall', 'gluScaleImage', 'int32_t', ['uint32_t', 'int32_t', 'int32_t', 'uint32_t', 'void *', 'int32_t', 'int32_t', 'uint32_t', 'void *']);
// gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout)
// format : DWORD -> 'uint32_t'
// widthin : INT -> 'int32_t'
// heightin : INT -> 'int32_t'
// typein : DWORD -> 'uint32_t'
// datain : void* -> 'void *'
// widthout : INT -> 'int32_t'
// heightout : INT -> 'int32_t'
// typeout : DWORD -> 'uint32_t'
// dataout : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GLU32.dll", {
gluScaleImage: { parameters: ["u32", "i32", "i32", "u32", "pointer", "i32", "i32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout)
// format : DWORD -> "u32"
// widthin : INT -> "i32"
// heightin : INT -> "i32"
// typein : DWORD -> "u32"
// datain : void* -> "pointer"
// widthout : INT -> "i32"
// heightout : INT -> "i32"
// typeout : DWORD -> "u32"
// dataout : void* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t gluScaleImage(
uint32_t format,
int32_t widthin,
int32_t heightin,
uint32_t typein,
void* datain,
int32_t widthout,
int32_t heightout,
uint32_t typeout,
void* dataout);
C, "GLU32.dll");
// $ffi->gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout);
// format : DWORD
// widthin : INT
// heightin : INT
// typein : DWORD
// datain : void*
// widthout : INT
// heightout : INT
// typeout : DWORD
// dataout : void* 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 Glu32 extends StdCallLibrary {
Glu32 INSTANCE = Native.load("glu32", Glu32.class);
int gluScaleImage(
int format, // DWORD
int widthin, // INT
int heightin, // INT
int typein, // DWORD
Pointer datain, // void*
int widthout, // INT
int heightout, // INT
int typeout, // DWORD
Pointer dataout // void* in/out
);
}@[Link("glu32")]
lib LibGLU32
fun gluScaleImage = gluScaleImage(
format : UInt32, # DWORD
widthin : Int32, # INT
heightin : Int32, # INT
typein : UInt32, # DWORD
datain : Void*, # void*
widthout : Int32, # INT
heightout : Int32, # INT
typeout : UInt32, # DWORD
dataout : Void* # void* 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 gluScaleImageNative = Int32 Function(Uint32, Int32, Int32, Uint32, Pointer<Void>, Int32, Int32, Uint32, Pointer<Void>);
typedef gluScaleImageDart = int Function(int, int, int, int, Pointer<Void>, int, int, int, Pointer<Void>);
final gluScaleImage = DynamicLibrary.open('GLU32.dll')
.lookupFunction<gluScaleImageNative, gluScaleImageDart>('gluScaleImage');
// format : DWORD -> Uint32
// widthin : INT -> Int32
// heightin : INT -> Int32
// typein : DWORD -> Uint32
// datain : void* -> Pointer<Void>
// widthout : INT -> Int32
// heightout : INT -> Int32
// typeout : DWORD -> Uint32
// dataout : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function gluScaleImage(
format: DWORD; // DWORD
widthin: Integer; // INT
heightin: Integer; // INT
typein: DWORD; // DWORD
datain: Pointer; // void*
widthout: Integer; // INT
heightout: Integer; // INT
typeout: DWORD; // DWORD
dataout: Pointer // void* in/out
): Integer; stdcall;
external 'GLU32.dll' name 'gluScaleImage';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "gluScaleImage"
c_gluScaleImage :: Word32 -> Int32 -> Int32 -> Word32 -> Ptr () -> Int32 -> Int32 -> Word32 -> Ptr () -> IO Int32
-- format : DWORD -> Word32
-- widthin : INT -> Int32
-- heightin : INT -> Int32
-- typein : DWORD -> Word32
-- datain : void* -> Ptr ()
-- widthout : INT -> Int32
-- heightout : INT -> Int32
-- typeout : DWORD -> Word32
-- dataout : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gluscaleimage =
foreign "gluScaleImage"
(uint32_t @-> int32_t @-> int32_t @-> uint32_t @-> (ptr void) @-> int32_t @-> int32_t @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* format : DWORD -> uint32_t *)
(* widthin : INT -> int32_t *)
(* heightin : INT -> int32_t *)
(* typein : DWORD -> uint32_t *)
(* datain : void* -> (ptr void) *)
(* widthout : INT -> int32_t *)
(* heightout : INT -> int32_t *)
(* typeout : DWORD -> uint32_t *)
(* dataout : void* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library glu32 (t "GLU32.dll"))
(cffi:use-foreign-library glu32)
(cffi:defcfun ("gluScaleImage" glu-scale-image :convention :stdcall) :int32
(format :uint32) ; DWORD
(widthin :int32) ; INT
(heightin :int32) ; INT
(typein :uint32) ; DWORD
(datain :pointer) ; void*
(widthout :int32) ; INT
(heightout :int32) ; INT
(typeout :uint32) ; DWORD
(dataout :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $gluScaleImage = Win32::API::More->new('GLU32',
'int gluScaleImage(DWORD format, int widthin, int heightin, DWORD typein, LPVOID datain, int widthout, int heightout, DWORD typeout, LPVOID dataout)');
# my $ret = $gluScaleImage->Call($format, $widthin, $heightin, $typein, $datain, $widthout, $heightout, $typeout, $dataout);
# format : DWORD -> DWORD
# widthin : INT -> int
# heightin : INT -> int
# typein : DWORD -> DWORD
# datain : void* -> LPVOID
# widthout : INT -> int
# heightout : INT -> int
# typeout : DWORD -> DWORD
# dataout : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。