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

BITMAPCOREHEADER

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

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

フィールド

フィールドサイズx64x86説明
bcSizeDWORD4+0+0この構造体のサイズ(バイト数)。種別の判別に用いる。
bcWidthWORD2+4+4ビットマップの幅(ピクセル数)。
bcHeightWORD2+6+6ビットマップの高さ(ピクセル数)。
bcPlanesWORD2+8+8対象デバイスのプレーン数。常に1。
bcBitCountWORD2+10+101ピクセルあたりのビット数(色深度)。

各言語での定義

#include <windows.h>

// BITMAPCOREHEADER  (x64 12 / x86 12 バイト)
typedef struct BITMAPCOREHEADER {
    DWORD bcSize;
    WORD bcWidth;
    WORD bcHeight;
    WORD bcPlanes;
    WORD bcBitCount;
} BITMAPCOREHEADER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BITMAPCOREHEADER
{
    public uint bcSize;
    public ushort bcWidth;
    public ushort bcHeight;
    public ushort bcPlanes;
    public ushort bcBitCount;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BITMAPCOREHEADER
    Public bcSize As UInteger
    Public bcWidth As UShort
    Public bcHeight As UShort
    Public bcPlanes As UShort
    Public bcBitCount As UShort
End Structure
import ctypes
from ctypes import wintypes

class BITMAPCOREHEADER(ctypes.Structure):
    _fields_ = [
        ("bcSize", wintypes.DWORD),
        ("bcWidth", ctypes.c_ushort),
        ("bcHeight", ctypes.c_ushort),
        ("bcPlanes", ctypes.c_ushort),
        ("bcBitCount", ctypes.c_ushort),
    ]
#[repr(C)]
pub struct BITMAPCOREHEADER {
    pub bcSize: u32,
    pub bcWidth: u16,
    pub bcHeight: u16,
    pub bcPlanes: u16,
    pub bcBitCount: u16,
}
import "golang.org/x/sys/windows"

type BITMAPCOREHEADER struct {
	bcSize uint32
	bcWidth uint16
	bcHeight uint16
	bcPlanes uint16
	bcBitCount uint16
}
type
  BITMAPCOREHEADER = record
    bcSize: DWORD;
    bcWidth: Word;
    bcHeight: Word;
    bcPlanes: Word;
    bcBitCount: Word;
  end;
const BITMAPCOREHEADER = extern struct {
    bcSize: u32,
    bcWidth: u16,
    bcHeight: u16,
    bcPlanes: u16,
    bcBitCount: u16,
};
type
  BITMAPCOREHEADER {.bycopy.} = object
    bcSize: uint32
    bcWidth: uint16
    bcHeight: uint16
    bcPlanes: uint16
    bcBitCount: uint16
struct BITMAPCOREHEADER
{
    uint bcSize;
    ushort bcWidth;
    ushort bcHeight;
    ushort bcPlanes;
    ushort bcBitCount;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BITMAPCOREHEADER サイズ: 12 バイト(x64)
dim st, 3    ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; bcSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; bcWidth : WORD (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; bcHeight : WORD (+6, 2byte)  wpoke st,6,値  /  値 = wpeek(st,6)
; bcPlanes : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; bcBitCount : WORD (+10, 2byte)  wpoke st,10,値  /  値 = wpeek(st,10)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BITMAPCOREHEADER
    #field int bcSize
    #field short bcWidth
    #field short bcHeight
    #field short bcPlanes
    #field short bcBitCount
#endstruct

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