Win32 API 日本語リファレンス
ホームSystem.SystemServices › userBITMAP

userBITMAP

構造体
サイズx64: 28 バイト / x86: 28 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
bmTypeINT4+0+0ビットマップの種類。常に 0。
bmWidthINT4+4+4ビットマップの幅。ピクセル単位。
bmHeightINT4+8+8ビットマップの高さ。ピクセル単位。
bmWidthBytesINT4+12+121 走査線あたりのバイト数。偶数に丸められる。
bmPlanesWORD2+16+16色プレーンの数。
bmBitsPixelWORD2+18+181 ピクセルあたりのビット数(色深度)。
cbSizeDWORD4+20+20pBuffer に続くビットマップビットのバイト数。
pBufferBYTE1+24+24ビットマップのピクセルデータを格納する可変長バイト配列の先頭。

各言語での定義

#include <windows.h>

// userBITMAP  (x64 28 / x86 28 バイト)
typedef struct userBITMAP {
    INT bmType;
    INT bmWidth;
    INT bmHeight;
    INT bmWidthBytes;
    WORD bmPlanes;
    WORD bmBitsPixel;
    DWORD cbSize;
    BYTE pBuffer[1];
} userBITMAP;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct userBITMAP
{
    public int bmType;
    public int bmWidth;
    public int bmHeight;
    public int bmWidthBytes;
    public ushort bmPlanes;
    public ushort bmBitsPixel;
    public uint cbSize;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] pBuffer;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure userBITMAP
    Public bmType As Integer
    Public bmWidth As Integer
    Public bmHeight As Integer
    Public bmWidthBytes As Integer
    Public bmPlanes As UShort
    Public bmBitsPixel As UShort
    Public cbSize As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public pBuffer() As Byte
End Structure
import ctypes
from ctypes import wintypes

class userBITMAP(ctypes.Structure):
    _fields_ = [
        ("bmType", ctypes.c_int),
        ("bmWidth", ctypes.c_int),
        ("bmHeight", ctypes.c_int),
        ("bmWidthBytes", ctypes.c_int),
        ("bmPlanes", ctypes.c_ushort),
        ("bmBitsPixel", ctypes.c_ushort),
        ("cbSize", wintypes.DWORD),
        ("pBuffer", ctypes.c_ubyte * 1),
    ]
#[repr(C)]
pub struct userBITMAP {
    pub bmType: i32,
    pub bmWidth: i32,
    pub bmHeight: i32,
    pub bmWidthBytes: i32,
    pub bmPlanes: u16,
    pub bmBitsPixel: u16,
    pub cbSize: u32,
    pub pBuffer: [u8; 1],
}
import "golang.org/x/sys/windows"

type userBITMAP struct {
	bmType int32
	bmWidth int32
	bmHeight int32
	bmWidthBytes int32
	bmPlanes uint16
	bmBitsPixel uint16
	cbSize uint32
	pBuffer [1]byte
}
type
  userBITMAP = record
    bmType: Integer;
    bmWidth: Integer;
    bmHeight: Integer;
    bmWidthBytes: Integer;
    bmPlanes: Word;
    bmBitsPixel: Word;
    cbSize: DWORD;
    pBuffer: array[0..0] of Byte;
  end;
const userBITMAP = extern struct {
    bmType: i32,
    bmWidth: i32,
    bmHeight: i32,
    bmWidthBytes: i32,
    bmPlanes: u16,
    bmBitsPixel: u16,
    cbSize: u32,
    pBuffer: [1]u8,
};
type
  userBITMAP {.bycopy.} = object
    bmType: int32
    bmWidth: int32
    bmHeight: int32
    bmWidthBytes: int32
    bmPlanes: uint16
    bmBitsPixel: uint16
    cbSize: uint32
    pBuffer: array[1, uint8]
struct userBITMAP
{
    int bmType;
    int bmWidth;
    int bmHeight;
    int bmWidthBytes;
    ushort bmPlanes;
    ushort bmBitsPixel;
    uint cbSize;
    ubyte[1] pBuffer;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; userBITMAP サイズ: 28 バイト(x64)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; bmType : INT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; bmWidth : INT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; bmHeight : INT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; bmWidthBytes : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; bmPlanes : WORD (+16, 2byte)  wpoke st,16,値  /  値 = wpeek(st,16)
; bmBitsPixel : WORD (+18, 2byte)  wpoke st,18,値  /  値 = wpeek(st,18)
; cbSize : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; pBuffer : BYTE (+24, 1byte)  varptr(st)+24 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global userBITMAP
    #field int bmType
    #field int bmWidth
    #field int bmHeight
    #field int bmWidthBytes
    #field short bmPlanes
    #field short bmBitsPixel
    #field int cbSize
    #field byte pBuffer 1
#endstruct

stdim st, userBITMAP        ; NSTRUCT 変数を確保
st->bmType = 100
mes "bmType=" + st->bmType