ホーム › Graphics.Gdi › BITMAP
BITMAP
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| bmType | INT | 4 | +0 | +0 | ビットマップの種別。常に0でなければならない。 |
| bmWidth | INT | 4 | +4 | +4 | ビットマップの幅(ピクセル数)。 |
| bmHeight | INT | 4 | +8 | +8 | ビットマップの高さ(ピクセル数)。 |
| bmWidthBytes | INT | 4 | +12 | +12 | 1走査線あたりのバイト数。偶数(WORD境界整列)である必要がある。 |
| bmPlanes | WORD | 2 | +16 | +16 | カラープレーンの数。 |
| bmBitsPixel | WORD | 2 | +18 | +18 | 1ピクセルあたりのビット数(色深度)。 |
| bmBits | void* | 8/4 | +24 | +20 | ビットマップのピクセルデータへのポインタ。 |
各言語での定義
#include <windows.h>
// BITMAP (x64 32 / x86 24 バイト)
typedef struct BITMAP {
INT bmType;
INT bmWidth;
INT bmHeight;
INT bmWidthBytes;
WORD bmPlanes;
WORD bmBitsPixel;
void* bmBits;
} BITMAP;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BITMAP
{
public int bmType;
public int bmWidth;
public int bmHeight;
public int bmWidthBytes;
public ushort bmPlanes;
public ushort bmBitsPixel;
public IntPtr bmBits;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BITMAP
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 bmBits As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class BITMAP(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),
("bmBits", ctypes.c_void_p),
]#[repr(C)]
pub struct BITMAP {
pub bmType: i32,
pub bmWidth: i32,
pub bmHeight: i32,
pub bmWidthBytes: i32,
pub bmPlanes: u16,
pub bmBitsPixel: u16,
pub bmBits: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type BITMAP struct {
bmType int32
bmWidth int32
bmHeight int32
bmWidthBytes int32
bmPlanes uint16
bmBitsPixel uint16
bmBits uintptr
}type
BITMAP = record
bmType: Integer;
bmWidth: Integer;
bmHeight: Integer;
bmWidthBytes: Integer;
bmPlanes: Word;
bmBitsPixel: Word;
bmBits: Pointer;
end;const BITMAP = extern struct {
bmType: i32,
bmWidth: i32,
bmHeight: i32,
bmWidthBytes: i32,
bmPlanes: u16,
bmBitsPixel: u16,
bmBits: ?*anyopaque,
};type
BITMAP {.bycopy.} = object
bmType: int32
bmWidth: int32
bmHeight: int32
bmWidthBytes: int32
bmPlanes: uint16
bmBitsPixel: uint16
bmBits: pointerstruct BITMAP
{
int bmType;
int bmWidth;
int bmHeight;
int bmWidthBytes;
ushort bmPlanes;
ushort bmBitsPixel;
void* bmBits;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; BITMAP サイズ: 24 バイト(x86)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 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)
; bmBits : void* (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BITMAP サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 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)
; bmBits : void* (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BITMAP
#field int bmType
#field int bmWidth
#field int bmHeight
#field int bmWidthBytes
#field short bmPlanes
#field short bmBitsPixel
#field intptr bmBits
#endstruct
stdim st, BITMAP ; NSTRUCT 変数を確保
st->bmType = 100
mes "bmType=" + st->bmType