ホーム › Graphics.Gdi › LineDDA
LineDDA
関数線分上の各点ごとにコールバックを呼び出す。
シグネチャ
// GDI32.dll
#include <windows.h>
BOOL LineDDA(
INT xStart,
INT yStart,
INT xEnd,
INT yEnd,
LINEDDAPROC lpProc,
LPARAM data // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| xStart | INT | in | 直線の始点の x 座標を論理単位で指定します。 |
| yStart | INT | in | 直線の始点の y 座標を論理単位で指定します。 |
| xEnd | INT | in | 直線の終点の x 座標を論理単位で指定します。 |
| yEnd | INT | in | 直線の終点の y 座標を論理単位で指定します。 |
| lpProc | LINEDDAPROC | in | アプリケーション定義のコールバック関数へのポインターです。詳細については、LineDDAProc コールバック関数を参照してください。 |
| data | LPARAM | inoptional | アプリケーション定義のデータへのポインターです。 |
戻り値の型: BOOL
公式ドキュメント
LineDDA 関数は、指定された始点と終点で定義される直線に対して、どのピクセルを強調表示すべきかを決定します。
戻り値
関数が成功した場合、戻り値は 0 以外の値になります。
関数が失敗した場合、戻り値は 0 になります。
解説(Remarks)
LineDDA 関数は、直線の終点を除く、直線上の各点の座標をアプリケーション定義のコールバック関数に渡します。座標を渡すのに加えて、この関数は既存のアプリケーション定義のデータも渡します。
コールバック関数に渡される座標がビデオディスプレイ上のピクセルと一致するのは、既定の変換とマッピングモードが使用されている場合のみです。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
BOOL LineDDA(
INT xStart,
INT yStart,
INT xEnd,
INT yEnd,
LINEDDAPROC lpProc,
LPARAM data // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool LineDDA(
int xStart, // INT
int yStart, // INT
int xEnd, // INT
int yEnd, // INT
IntPtr lpProc, // LINEDDAPROC
IntPtr data // LPARAM optional
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function LineDDA(
xStart As Integer, ' INT
yStart As Integer, ' INT
xEnd As Integer, ' INT
yEnd As Integer, ' INT
lpProc As IntPtr, ' LINEDDAPROC
data As IntPtr ' LPARAM optional
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' xStart : INT
' yStart : INT
' xEnd : INT
' yEnd : INT
' lpProc : LINEDDAPROC
' data : LPARAM optional
Declare PtrSafe Function LineDDA Lib "gdi32" ( _
ByVal xStart As Long, _
ByVal yStart As Long, _
ByVal xEnd As Long, _
ByVal yEnd As Long, _
ByVal lpProc As LongPtr, _
ByVal data As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LineDDA = ctypes.windll.gdi32.LineDDA
LineDDA.restype = wintypes.BOOL
LineDDA.argtypes = [
ctypes.c_int, # xStart : INT
ctypes.c_int, # yStart : INT
ctypes.c_int, # xEnd : INT
ctypes.c_int, # yEnd : INT
ctypes.c_void_p, # lpProc : LINEDDAPROC
ctypes.c_ssize_t, # data : LPARAM optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
LineDDA = Fiddle::Function.new(
lib['LineDDA'],
[
Fiddle::TYPE_INT, # xStart : INT
Fiddle::TYPE_INT, # yStart : INT
Fiddle::TYPE_INT, # xEnd : INT
Fiddle::TYPE_INT, # yEnd : INT
Fiddle::TYPE_VOIDP, # lpProc : LINEDDAPROC
Fiddle::TYPE_INTPTR_T, # data : LPARAM optional
],
Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn LineDDA(
xStart: i32, // INT
yStart: i32, // INT
xEnd: i32, // INT
yEnd: i32, // INT
lpProc: *const core::ffi::c_void, // LINEDDAPROC
data: isize // LPARAM optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool LineDDA(int xStart, int yStart, int xEnd, int yEnd, IntPtr lpProc, IntPtr data);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_LineDDA' -Namespace Win32 -PassThru
# $api::LineDDA(xStart, yStart, xEnd, yEnd, lpProc, data)#uselib "GDI32.dll"
#func global LineDDA "LineDDA" sptr, sptr, sptr, sptr, sptr, sptr
; LineDDA xStart, yStart, xEnd, yEnd, lpProc, data ; 戻り値は stat
; xStart : INT -> "sptr"
; yStart : INT -> "sptr"
; xEnd : INT -> "sptr"
; yEnd : INT -> "sptr"
; lpProc : LINEDDAPROC -> "sptr"
; data : LPARAM optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "GDI32.dll"
#cfunc global LineDDA "LineDDA" int, int, int, int, sptr, sptr
; res = LineDDA(xStart, yStart, xEnd, yEnd, lpProc, data)
; xStart : INT -> "int"
; yStart : INT -> "int"
; xEnd : INT -> "int"
; yEnd : INT -> "int"
; lpProc : LINEDDAPROC -> "sptr"
; data : LPARAM optional -> "sptr"; BOOL LineDDA(INT xStart, INT yStart, INT xEnd, INT yEnd, LINEDDAPROC lpProc, LPARAM data)
#uselib "GDI32.dll"
#cfunc global LineDDA "LineDDA" int, int, int, int, intptr, intptr
; res = LineDDA(xStart, yStart, xEnd, yEnd, lpProc, data)
; xStart : INT -> "int"
; yStart : INT -> "int"
; xEnd : INT -> "int"
; yEnd : INT -> "int"
; lpProc : LINEDDAPROC -> "intptr"
; data : LPARAM optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procLineDDA = gdi32.NewProc("LineDDA")
)
// xStart (INT), yStart (INT), xEnd (INT), yEnd (INT), lpProc (LINEDDAPROC), data (LPARAM optional)
r1, _, err := procLineDDA.Call(
uintptr(xStart),
uintptr(yStart),
uintptr(xEnd),
uintptr(yEnd),
uintptr(lpProc),
uintptr(data),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction LineDDA(
xStart: Integer; // INT
yStart: Integer; // INT
xEnd: Integer; // INT
yEnd: Integer; // INT
lpProc: Pointer; // LINEDDAPROC
data: NativeInt // LPARAM optional
): BOOL; stdcall;
external 'GDI32.dll' name 'LineDDA';result := DllCall("GDI32\LineDDA"
, "Int", xStart ; INT
, "Int", yStart ; INT
, "Int", xEnd ; INT
, "Int", yEnd ; INT
, "Ptr", lpProc ; LINEDDAPROC
, "Ptr", data ; LPARAM optional
, "Int") ; return: BOOL●LineDDA(xStart, yStart, xEnd, yEnd, lpProc, data) = DLL("GDI32.dll", "bool LineDDA(int, int, int, int, void*, int)")
# 呼び出し: LineDDA(xStart, yStart, xEnd, yEnd, lpProc, data)
# xStart : INT -> "int"
# yStart : INT -> "int"
# xEnd : INT -> "int"
# yEnd : INT -> "int"
# lpProc : LINEDDAPROC -> "void*"
# data : LPARAM optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdi32" fn LineDDA(
xStart: i32, // INT
yStart: i32, // INT
xEnd: i32, // INT
yEnd: i32, // INT
lpProc: ?*anyopaque, // LINEDDAPROC
data: isize // LPARAM optional
) callconv(std.os.windows.WINAPI) i32;proc LineDDA(
xStart: int32, # INT
yStart: int32, # INT
xEnd: int32, # INT
yEnd: int32, # INT
lpProc: pointer, # LINEDDAPROC
data: int # LPARAM optional
): int32 {.importc: "LineDDA", stdcall, dynlib: "GDI32.dll".}pragma(lib, "gdi32");
extern(Windows)
int LineDDA(
int xStart, // INT
int yStart, // INT
int xEnd, // INT
int yEnd, // INT
void* lpProc, // LINEDDAPROC
ptrdiff_t data // LPARAM optional
);ccall((:LineDDA, "GDI32.dll"), stdcall, Int32,
(Int32, Int32, Int32, Int32, Ptr{Cvoid}, Int),
xStart, yStart, xEnd, yEnd, lpProc, data)
# xStart : INT -> Int32
# yStart : INT -> Int32
# xEnd : INT -> Int32
# yEnd : INT -> Int32
# lpProc : LINEDDAPROC -> Ptr{Cvoid}
# data : LPARAM optional -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t LineDDA(
int32_t xStart,
int32_t yStart,
int32_t xEnd,
int32_t yEnd,
void* lpProc,
intptr_t data);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.LineDDA(xStart, yStart, xEnd, yEnd, lpProc, data)
-- xStart : INT
-- yStart : INT
-- xEnd : INT
-- yEnd : INT
-- lpProc : LINEDDAPROC
-- data : LPARAM optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const LineDDA = lib.func('__stdcall', 'LineDDA', 'int32_t', ['int32_t', 'int32_t', 'int32_t', 'int32_t', 'void *', 'intptr_t']);
// LineDDA(xStart, yStart, xEnd, yEnd, lpProc, data)
// xStart : INT -> 'int32_t'
// yStart : INT -> 'int32_t'
// xEnd : INT -> 'int32_t'
// yEnd : INT -> 'int32_t'
// lpProc : LINEDDAPROC -> 'void *'
// data : LPARAM optional -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("GDI32.dll", {
LineDDA: { parameters: ["i32", "i32", "i32", "i32", "pointer", "isize"], result: "i32" },
});
// lib.symbols.LineDDA(xStart, yStart, xEnd, yEnd, lpProc, data)
// xStart : INT -> "i32"
// yStart : INT -> "i32"
// xEnd : INT -> "i32"
// yEnd : INT -> "i32"
// lpProc : LINEDDAPROC -> "pointer"
// data : LPARAM optional -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t LineDDA(
int32_t xStart,
int32_t yStart,
int32_t xEnd,
int32_t yEnd,
void* lpProc,
intptr_t data);
C, "GDI32.dll");
// $ffi->LineDDA(xStart, yStart, xEnd, yEnd, lpProc, data);
// xStart : INT
// yStart : INT
// xEnd : INT
// yEnd : INT
// lpProc : LINEDDAPROC
// data : LPARAM optional
// 構造体/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 Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class);
boolean LineDDA(
int xStart, // INT
int yStart, // INT
int xEnd, // INT
int yEnd, // INT
Callback lpProc, // LINEDDAPROC
long data // LPARAM optional
);
}@[Link("gdi32")]
lib LibGDI32
fun LineDDA = LineDDA(
xStart : Int32, # INT
yStart : Int32, # INT
xEnd : Int32, # INT
yEnd : Int32, # INT
lpProc : Void*, # LINEDDAPROC
data : LibC::SSizeT # LPARAM optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef LineDDANative = Int32 Function(Int32, Int32, Int32, Int32, Pointer<Void>, IntPtr);
typedef LineDDADart = int Function(int, int, int, int, Pointer<Void>, int);
final LineDDA = DynamicLibrary.open('GDI32.dll')
.lookupFunction<LineDDANative, LineDDADart>('LineDDA');
// xStart : INT -> Int32
// yStart : INT -> Int32
// xEnd : INT -> Int32
// yEnd : INT -> Int32
// lpProc : LINEDDAPROC -> Pointer<Void>
// data : LPARAM optional -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function LineDDA(
xStart: Integer; // INT
yStart: Integer; // INT
xEnd: Integer; // INT
yEnd: Integer; // INT
lpProc: Pointer; // LINEDDAPROC
data: NativeInt // LPARAM optional
): BOOL; stdcall;
external 'GDI32.dll' name 'LineDDA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "LineDDA"
c_LineDDA :: Int32 -> Int32 -> Int32 -> Int32 -> Ptr () -> CIntPtr -> IO CInt
-- xStart : INT -> Int32
-- yStart : INT -> Int32
-- xEnd : INT -> Int32
-- yEnd : INT -> Int32
-- lpProc : LINEDDAPROC -> Ptr ()
-- data : LPARAM optional -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let linedda =
foreign "LineDDA"
(int32_t @-> int32_t @-> int32_t @-> int32_t @-> (ptr void) @-> intptr_t @-> returning int32_t)
(* xStart : INT -> int32_t *)
(* yStart : INT -> int32_t *)
(* xEnd : INT -> int32_t *)
(* yEnd : INT -> int32_t *)
(* lpProc : LINEDDAPROC -> (ptr void) *)
(* data : LPARAM optional -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)
(cffi:defcfun ("LineDDA" line-dda :convention :stdcall) :int32
(x-start :int32) ; INT
(y-start :int32) ; INT
(x-end :int32) ; INT
(y-end :int32) ; INT
(lp-proc :pointer) ; LINEDDAPROC
(data :int64)) ; LPARAM optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $LineDDA = Win32::API::More->new('GDI32',
'BOOL LineDDA(int xStart, int yStart, int xEnd, int yEnd, LPVOID lpProc, LPARAM data)');
# my $ret = $LineDDA->Call($xStart, $yStart, $xEnd, $yEnd, $lpProc, $data);
# xStart : INT -> int
# yStart : INT -> int
# xEnd : INT -> int
# yEnd : INT -> int
# lpProc : LINEDDAPROC -> LPVOID
# data : LPARAM optional -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。関連項目
使用する型