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 ピクセルあたりのビット数。この値は 1、4、8、または 24 でなければなりません。

公式ドキュメント

BITMAPCOREHEADER 構造体は、DIB の寸法と色形式に関する情報を保持します。

解説(Remarks)

BITMAPCOREINFO 構造体は、BITMAPCOREHEADER 構造体とカラーテーブルを組み合わせて、DIB の寸法と色の完全な定義を提供します。DIB の指定方法の詳細については、BITMAPCOREINFO を参照してください。

アプリケーションは、bcSize メンバーに格納された情報を使用して、次のような方法で BITMAPCOREINFO 構造体内のカラーテーブルの位置を特定する必要があります。


pColor = ((LPBYTE) pBitmapCoreInfo + 
        (WORD) (pBitmapCoreInfo -> bcSize)) 
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#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