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

GdipSetLineColors

関数
線形グラデーションブラシの開始色と終了色を設定する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipSetLineColors(
    GpLineGradient* brush,
    DWORD color1,
    DWORD color2
);

パラメーター

名前方向説明
brushGpLineGradient*inout対象の線形グラデーションブラシへのポインタ。
color1DWORDin開始色をARGB形式で指定する32ビット値。
color2DWORDin終了色をARGB形式で指定する32ビット値。

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipSetLineColors(
    GpLineGradient* brush,
    DWORD color1,
    DWORD color2
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipSetLineColors(
    IntPtr brush,   // GpLineGradient* in/out
    uint color1,   // DWORD
    uint color2   // DWORD
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipSetLineColors(
    brush As IntPtr,   ' GpLineGradient* in/out
    color1 As UInteger,   ' DWORD
    color2 As UInteger   ' DWORD
) As Integer
End Function
' brush : GpLineGradient* in/out
' color1 : DWORD
' color2 : DWORD
Declare PtrSafe Function GdipSetLineColors Lib "gdiplus" ( _
    ByVal brush As LongPtr, _
    ByVal color1 As Long, _
    ByVal color2 As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipSetLineColors = ctypes.windll.gdiplus.GdipSetLineColors
GdipSetLineColors.restype = ctypes.c_int
GdipSetLineColors.argtypes = [
    ctypes.c_void_p,  # brush : GpLineGradient* in/out
    wintypes.DWORD,  # color1 : DWORD
    wintypes.DWORD,  # color2 : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipSetLineColors = gdiplus.NewProc("GdipSetLineColors")
)

// brush (GpLineGradient* in/out), color1 (DWORD), color2 (DWORD)
r1, _, err := procGdipSetLineColors.Call(
	uintptr(brush),
	uintptr(color1),
	uintptr(color2),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipSetLineColors(
  brush: Pointer;   // GpLineGradient* in/out
  color1: DWORD;   // DWORD
  color2: DWORD   // DWORD
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipSetLineColors';
result := DllCall("gdiplus\GdipSetLineColors"
    , "Ptr", brush   ; GpLineGradient* in/out
    , "UInt", color1   ; DWORD
    , "UInt", color2   ; DWORD
    , "Int")   ; return: Status
●GdipSetLineColors(brush, color1, color2) = DLL("gdiplus.dll", "int GdipSetLineColors(void*, dword, dword)")
# 呼び出し: GdipSetLineColors(brush, color1, color2)
# brush : GpLineGradient* in/out -> "void*"
# color1 : DWORD -> "dword"
# color2 : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef GdipSetLineColorsNative = Int32 Function(Pointer<Void>, Uint32, Uint32);
typedef GdipSetLineColorsDart = int Function(Pointer<Void>, int, int);
final GdipSetLineColors = DynamicLibrary.open('gdiplus.dll')
    .lookupFunction<GdipSetLineColorsNative, GdipSetLineColorsDart>('GdipSetLineColors');
// brush : GpLineGradient* in/out -> Pointer<Void>
// color1 : DWORD -> Uint32
// color2 : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GdipSetLineColors(
  brush: Pointer;   // GpLineGradient* in/out
  color1: DWORD;   // DWORD
  color2: DWORD   // DWORD
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipSetLineColors';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GdipSetLineColors"
  c_GdipSetLineColors :: Ptr () -> Word32 -> Word32 -> IO Int32
-- brush : GpLineGradient* in/out -> Ptr ()
-- color1 : DWORD -> Word32
-- color2 : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let gdipsetlinecolors =
  foreign "GdipSetLineColors"
    ((ptr void) @-> uint32_t @-> uint32_t @-> returning int32_t)
(* brush : GpLineGradient* in/out -> (ptr void) *)
(* color1 : DWORD -> uint32_t *)
(* color2 : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)

(cffi:defcfun ("GdipSetLineColors" gdip-set-line-colors :convention :stdcall) :int32
  (brush :pointer)   ; GpLineGradient* in/out
  (color1 :uint32)   ; DWORD
  (color2 :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GdipSetLineColors = Win32::API::More->new('gdiplus',
    'int GdipSetLineColors(LPVOID brush, DWORD color1, DWORD color2)');
# my $ret = $GdipSetLineColors->Call($brush, $color1, $color2);
# brush : GpLineGradient* in/out -> LPVOID
# color1 : DWORD -> DWORD
# color2 : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型