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

GdipBitmapSetPixel

関数
ビットマップの指定座標のピクセル色を設定する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipBitmapSetPixel(
    GpBitmap* bitmap,
    INT x,
    INT y,
    DWORD color
);

パラメーター

名前方向
bitmapGpBitmap*inout
xINTin
yINTin
colorDWORDin

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // Status
function 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)。