ホーム › 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 | ビットマップの幅 (ピクセル単位) です。幅は 0 より大きくなければなりません。 |
| bmHeight | INT | 4 | +8 | +8 | ビットマップの高さ (ピクセル単位) です。高さは 0 より大きくなければなりません。 |
| bmWidthBytes | INT | 4 | +12 | +12 | 各走査線のバイト数です。システムはビットマップのビット値がワード境界に整列した配列を構成すると想定するため、この値は 2 で割り切れなければなりません。 |
| bmPlanes | WORD | 2 | +16 | +16 | カラープレーンの数です。 |
| bmBitsPixel | WORD | 2 | +18 | +18 | 1 ピクセルの色を表すために必要なビット数です。 |
| bmBits | void* | 8/4 | +24 | +20 | ビットマップのビット値が格納されている位置へのポインターです。bmBits メンバーは、文字型 (1 バイト) の値の配列へのポインターでなければなりません。 |
公式ドキュメント
BITMAP 構造体は、ビットマップの種類、幅、高さ、カラー形式、およびビット値を定義します。
解説(Remarks)
現在使用されているビットマップ形式は、モノクロとカラーです。モノクロビットマップは 1 ビット 1 プレーン形式を使用します。各走査線は 16 ビットの倍数です。
高さが n のモノクロビットマップでは、走査線は次のように構成されます。
Scan 0
Scan 1
.
.
.
Scan n-2
Scan n-1
モノクロデバイス上のピクセルは黒または白のいずれかです。ビットマップ内の対応するビットが 1 の場合、そのピクセルには前景色が設定されます。対応するビットが 0 の場合、そのピクセルには背景色が設定されます。
RC_BITBLT デバイス機能を備えたすべてのデバイスがビットマップをサポートします。詳細については、GetDeviceCaps を参照してください。
各デバイスは固有のカラー形式を持ちます。ビットマップをあるデバイスから別のデバイスへ転送するには、GetDIBits 関数および SetDIBits 関数を使用します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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