ホーム › Graphics.GdiPlus › GdipBitmapSetPixel
GdipBitmapSetPixel
関数ビットマップの指定座標のピクセル色を設定する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipBitmapSetPixel(
GpBitmap* bitmap,
INT x,
INT y,
DWORD color
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| bitmap | GpBitmap* | inout | 対象のGpBitmapオブジェクトへのポインタ。 |
| x | INT | in | 設定するピクセルのX座標(0起点の整数)。 |
| y | INT | in | 設定するピクセルのY座標(0起点の整数)。 |
| color | DWORD | in | 設定する色をARGB形式で指定するDWORD値。 |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipBitmapSetPixel(
GpBitmap* bitmap,
INT x,
INT y,
DWORD color
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipBitmapSetPixel(
IntPtr bitmap, // GpBitmap* in/out
int x, // INT
int y, // INT
uint color // DWORD
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipBitmapSetPixel(
bitmap As IntPtr, ' GpBitmap* in/out
x As Integer, ' INT
y As Integer, ' INT
color As UInteger ' DWORD
) As Integer
End Function' bitmap : GpBitmap* in/out
' x : INT
' y : INT
' color : DWORD
Declare PtrSafe Function GdipBitmapSetPixel Lib "gdiplus" ( _
ByVal bitmap As LongPtr, _
ByVal x As Long, _
ByVal y As Long, _
ByVal color As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdipBitmapSetPixel = ctypes.windll.gdiplus.GdipBitmapSetPixel
GdipBitmapSetPixel.restype = ctypes.c_int
GdipBitmapSetPixel.argtypes = [
ctypes.c_void_p, # bitmap : GpBitmap* in/out
ctypes.c_int, # x : INT
ctypes.c_int, # y : INT
wintypes.DWORD, # color : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipBitmapSetPixel = Fiddle::Function.new(
lib['GdipBitmapSetPixel'],
[
Fiddle::TYPE_VOIDP, # bitmap : GpBitmap* in/out
Fiddle::TYPE_INT, # x : INT
Fiddle::TYPE_INT, # y : INT
-Fiddle::TYPE_INT, # color : DWORD
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipBitmapSetPixel(
bitmap: *mut GpBitmap, // GpBitmap* in/out
x: i32, // INT
y: i32, // INT
color: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipBitmapSetPixel(IntPtr bitmap, int x, int y, uint color);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipBitmapSetPixel' -Namespace Win32 -PassThru
# $api::GdipBitmapSetPixel(bitmap, x, y, color)#uselib "gdiplus.dll"
#func global GdipBitmapSetPixel "GdipBitmapSetPixel" sptr, sptr, sptr, sptr
; GdipBitmapSetPixel varptr(bitmap), x, y, color ; 戻り値は stat
; bitmap : GpBitmap* in/out -> "sptr"
; x : INT -> "sptr"
; y : INT -> "sptr"
; color : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipBitmapSetPixel "GdipBitmapSetPixel" var, int, int, int ; res = GdipBitmapSetPixel(bitmap, x, y, color) ; bitmap : GpBitmap* in/out -> "var" ; x : INT -> "int" ; y : INT -> "int" ; color : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipBitmapSetPixel "GdipBitmapSetPixel" sptr, int, int, int ; res = GdipBitmapSetPixel(varptr(bitmap), x, y, color) ; bitmap : GpBitmap* in/out -> "sptr" ; x : INT -> "int" ; y : INT -> "int" ; color : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipBitmapSetPixel(GpBitmap* bitmap, INT x, INT y, DWORD color) #uselib "gdiplus.dll" #cfunc global GdipBitmapSetPixel "GdipBitmapSetPixel" var, int, int, int ; res = GdipBitmapSetPixel(bitmap, x, y, color) ; bitmap : GpBitmap* in/out -> "var" ; x : INT -> "int" ; y : INT -> "int" ; color : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipBitmapSetPixel(GpBitmap* bitmap, INT x, INT y, DWORD color) #uselib "gdiplus.dll" #cfunc global GdipBitmapSetPixel "GdipBitmapSetPixel" intptr, int, int, int ; res = GdipBitmapSetPixel(varptr(bitmap), x, y, color) ; bitmap : GpBitmap* in/out -> "intptr" ; x : INT -> "int" ; y : INT -> "int" ; color : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipBitmapSetPixel = gdiplus.NewProc("GdipBitmapSetPixel")
)
// bitmap (GpBitmap* in/out), x (INT), y (INT), color (DWORD)
r1, _, err := procGdipBitmapSetPixel.Call(
uintptr(bitmap),
uintptr(x),
uintptr(y),
uintptr(color),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Statusfunction GdipBitmapSetPixel(
bitmap: Pointer; // GpBitmap* in/out
x: Integer; // INT
y: Integer; // INT
color: DWORD // DWORD
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipBitmapSetPixel';result := DllCall("gdiplus\GdipBitmapSetPixel"
, "Ptr", bitmap ; GpBitmap* in/out
, "Int", x ; INT
, "Int", y ; INT
, "UInt", color ; DWORD
, "Int") ; return: Status●GdipBitmapSetPixel(bitmap, x, y, color) = DLL("gdiplus.dll", "int GdipBitmapSetPixel(void*, int, int, dword)")
# 呼び出し: GdipBitmapSetPixel(bitmap, x, y, color)
# bitmap : GpBitmap* in/out -> "void*"
# x : INT -> "int"
# y : INT -> "int"
# color : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdiplus" fn GdipBitmapSetPixel(
bitmap: [*c]GpBitmap, // GpBitmap* in/out
x: i32, // INT
y: i32, // INT
color: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc GdipBitmapSetPixel(
bitmap: ptr GpBitmap, # GpBitmap* in/out
x: int32, # INT
y: int32, # INT
color: uint32 # DWORD
): int32 {.importc: "GdipBitmapSetPixel", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipBitmapSetPixel(
GpBitmap* bitmap, // GpBitmap* in/out
int x, // INT
int y, // INT
uint color // DWORD
);ccall((:GdipBitmapSetPixel, "gdiplus.dll"), stdcall, Int32,
(Ptr{GpBitmap}, Int32, Int32, UInt32),
bitmap, x, y, color)
# bitmap : GpBitmap* in/out -> Ptr{GpBitmap}
# x : INT -> Int32
# y : INT -> Int32
# color : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipBitmapSetPixel(
void* bitmap,
int32_t x,
int32_t y,
uint32_t color);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipBitmapSetPixel(bitmap, x, y, color)
-- bitmap : GpBitmap* in/out
-- x : INT
-- y : INT
-- color : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipBitmapSetPixel = lib.func('__stdcall', 'GdipBitmapSetPixel', 'int32_t', ['void *', 'int32_t', 'int32_t', 'uint32_t']);
// GdipBitmapSetPixel(bitmap, x, y, color)
// bitmap : GpBitmap* in/out -> 'void *'
// x : INT -> 'int32_t'
// y : INT -> 'int32_t'
// color : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipBitmapSetPixel: { parameters: ["pointer", "i32", "i32", "u32"], result: "i32" },
});
// lib.symbols.GdipBitmapSetPixel(bitmap, x, y, color)
// bitmap : GpBitmap* in/out -> "pointer"
// x : INT -> "i32"
// y : INT -> "i32"
// color : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipBitmapSetPixel(
void* bitmap,
int32_t x,
int32_t y,
uint32_t color);
C, "gdiplus.dll");
// $ffi->GdipBitmapSetPixel(bitmap, x, y, color);
// bitmap : GpBitmap* in/out
// x : INT
// y : INT
// color : 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 GdipBitmapSetPixel(
Pointer bitmap, // GpBitmap* in/out
int x, // INT
int y, // INT
int color // DWORD
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipBitmapSetPixel = GdipBitmapSetPixel(
bitmap : GpBitmap*, # GpBitmap* in/out
x : Int32, # INT
y : Int32, # INT
color : 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 GdipBitmapSetPixelNative = Int32 Function(Pointer<Void>, Int32, Int32, Uint32);
typedef GdipBitmapSetPixelDart = int Function(Pointer<Void>, int, int, int);
final GdipBitmapSetPixel = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipBitmapSetPixelNative, GdipBitmapSetPixelDart>('GdipBitmapSetPixel');
// bitmap : GpBitmap* in/out -> Pointer<Void>
// x : INT -> Int32
// y : INT -> Int32
// color : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GdipBitmapSetPixel(
bitmap: Pointer; // GpBitmap* in/out
x: Integer; // INT
y: Integer; // INT
color: DWORD // DWORD
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipBitmapSetPixel';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipBitmapSetPixel"
c_GdipBitmapSetPixel :: Ptr () -> Int32 -> Int32 -> Word32 -> IO Int32
-- bitmap : GpBitmap* in/out -> Ptr ()
-- x : INT -> Int32
-- y : INT -> Int32
-- color : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipbitmapsetpixel =
foreign "GdipBitmapSetPixel"
((ptr void) @-> int32_t @-> int32_t @-> uint32_t @-> returning int32_t)
(* bitmap : GpBitmap* in/out -> (ptr void) *)
(* x : INT -> int32_t *)
(* y : INT -> int32_t *)
(* color : 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 ("GdipBitmapSetPixel" gdip-bitmap-set-pixel :convention :stdcall) :int32
(bitmap :pointer) ; GpBitmap* in/out
(x :int32) ; INT
(y :int32) ; INT
(color :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipBitmapSetPixel = Win32::API::More->new('gdiplus',
'int GdipBitmapSetPixel(LPVOID bitmap, int x, int y, DWORD color)');
# my $ret = $GdipBitmapSetPixel->Call($bitmap, $x, $y, $color);
# bitmap : GpBitmap* in/out -> LPVOID
# x : INT -> int
# y : INT -> int
# color : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型