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

BITMAPV4HEADER

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

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

フィールド

フィールドサイズx64x86説明
bV4SizeDWORD4+0+0この構造体のサイズ(バイト数)。
bV4WidthINT4+4+4ビットマップの幅(ピクセル数)。
bV4HeightINT4+8+8ビットマップの高さ。正でボトムアップ、負でトップダウン。
bV4PlanesWORD2+12+12対象デバイスのプレーン数。常に1。
bV4BitCountWORD2+14+141ピクセルあたりのビット数(色深度)。
bV4V4CompressionBI_COMPRESSION4+16+16ビットマップの圧縮形式を示すBI_COMPRESSION列挙値。
bV4SizeImageDWORD4+20+20画像データのバイト数。
bV4XPelsPerMeterINT4+24+24水平方向の解像度(1メートルあたりのピクセル数)。
bV4YPelsPerMeterINT4+28+28垂直方向の解像度(1メートルあたりのピクセル数)。
bV4ClrUsedDWORD4+32+32実際に使用するカラーテーブルの色数。0で最大数を使用。
bV4ClrImportantDWORD4+36+36表示に重要な色数。0で全色が重要。
bV4RedMaskDWORD4+40+40赤成分を抽出するためのカラーマスク。
bV4GreenMaskDWORD4+44+44緑成分を抽出するためのカラーマスク。
bV4BlueMaskDWORD4+48+48青成分を抽出するためのカラーマスク。
bV4AlphaMaskDWORD4+52+52アルファ成分を抽出するためのカラーマスク。
bV4CSTypeDWORD4+56+56ビットマップの色空間種別を示す値。
bV4EndpointsCIEXYZTRIPLE36+60+60色空間の原色エンドポイント座標を表すCIEXYZTRIPLE。
bV4GammaRedDWORD4+96+96赤チャンネルのガンマ値(16.16固定小数点)。
bV4GammaGreenDWORD4+100+100緑チャンネルのガンマ値(16.16固定小数点)。
bV4GammaBlueDWORD4+104+104青チャンネルのガンマ値(16.16固定小数点)。

各言語での定義

#include <windows.h>

// CIEXYZ  (x64 12 / x86 12 バイト)
typedef struct CIEXYZ {
    INT ciexyzX;
    INT ciexyzY;
    INT ciexyzZ;
} CIEXYZ;

// CIEXYZTRIPLE  (x64 36 / x86 36 バイト)
typedef struct CIEXYZTRIPLE {
    CIEXYZ ciexyzRed;
    CIEXYZ ciexyzGreen;
    CIEXYZ ciexyzBlue;
} CIEXYZTRIPLE;

// BITMAPV4HEADER  (x64 108 / x86 108 バイト)
typedef struct BITMAPV4HEADER {
    DWORD bV4Size;
    INT bV4Width;
    INT bV4Height;
    WORD bV4Planes;
    WORD bV4BitCount;
    BI_COMPRESSION bV4V4Compression;
    DWORD bV4SizeImage;
    INT bV4XPelsPerMeter;
    INT bV4YPelsPerMeter;
    DWORD bV4ClrUsed;
    DWORD bV4ClrImportant;
    DWORD bV4RedMask;
    DWORD bV4GreenMask;
    DWORD bV4BlueMask;
    DWORD bV4AlphaMask;
    DWORD bV4CSType;
    CIEXYZTRIPLE bV4Endpoints;
    DWORD bV4GammaRed;
    DWORD bV4GammaGreen;
    DWORD bV4GammaBlue;
} BITMAPV4HEADER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CIEXYZ
{
    public int ciexyzX;
    public int ciexyzY;
    public int ciexyzZ;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CIEXYZTRIPLE
{
    public CIEXYZ ciexyzRed;
    public CIEXYZ ciexyzGreen;
    public CIEXYZ ciexyzBlue;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BITMAPV4HEADER
{
    public uint bV4Size;
    public int bV4Width;
    public int bV4Height;
    public ushort bV4Planes;
    public ushort bV4BitCount;
    public uint bV4V4Compression;
    public uint bV4SizeImage;
    public int bV4XPelsPerMeter;
    public int bV4YPelsPerMeter;
    public uint bV4ClrUsed;
    public uint bV4ClrImportant;
    public uint bV4RedMask;
    public uint bV4GreenMask;
    public uint bV4BlueMask;
    public uint bV4AlphaMask;
    public uint bV4CSType;
    public CIEXYZTRIPLE bV4Endpoints;
    public uint bV4GammaRed;
    public uint bV4GammaGreen;
    public uint bV4GammaBlue;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CIEXYZ
    Public ciexyzX As Integer
    Public ciexyzY As Integer
    Public ciexyzZ As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CIEXYZTRIPLE
    Public ciexyzRed As CIEXYZ
    Public ciexyzGreen As CIEXYZ
    Public ciexyzBlue As CIEXYZ
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BITMAPV4HEADER
    Public bV4Size As UInteger
    Public bV4Width As Integer
    Public bV4Height As Integer
    Public bV4Planes As UShort
    Public bV4BitCount As UShort
    Public bV4V4Compression As UInteger
    Public bV4SizeImage As UInteger
    Public bV4XPelsPerMeter As Integer
    Public bV4YPelsPerMeter As Integer
    Public bV4ClrUsed As UInteger
    Public bV4ClrImportant As UInteger
    Public bV4RedMask As UInteger
    Public bV4GreenMask As UInteger
    Public bV4BlueMask As UInteger
    Public bV4AlphaMask As UInteger
    Public bV4CSType As UInteger
    Public bV4Endpoints As CIEXYZTRIPLE
    Public bV4GammaRed As UInteger
    Public bV4GammaGreen As UInteger
    Public bV4GammaBlue As UInteger
End Structure
import ctypes
from ctypes import wintypes

class CIEXYZ(ctypes.Structure):
    _fields_ = [
        ("ciexyzX", ctypes.c_int),
        ("ciexyzY", ctypes.c_int),
        ("ciexyzZ", ctypes.c_int),
    ]

class CIEXYZTRIPLE(ctypes.Structure):
    _fields_ = [
        ("ciexyzRed", CIEXYZ),
        ("ciexyzGreen", CIEXYZ),
        ("ciexyzBlue", CIEXYZ),
    ]

class BITMAPV4HEADER(ctypes.Structure):
    _fields_ = [
        ("bV4Size", wintypes.DWORD),
        ("bV4Width", ctypes.c_int),
        ("bV4Height", ctypes.c_int),
        ("bV4Planes", ctypes.c_ushort),
        ("bV4BitCount", ctypes.c_ushort),
        ("bV4V4Compression", wintypes.DWORD),
        ("bV4SizeImage", wintypes.DWORD),
        ("bV4XPelsPerMeter", ctypes.c_int),
        ("bV4YPelsPerMeter", ctypes.c_int),
        ("bV4ClrUsed", wintypes.DWORD),
        ("bV4ClrImportant", wintypes.DWORD),
        ("bV4RedMask", wintypes.DWORD),
        ("bV4GreenMask", wintypes.DWORD),
        ("bV4BlueMask", wintypes.DWORD),
        ("bV4AlphaMask", wintypes.DWORD),
        ("bV4CSType", wintypes.DWORD),
        ("bV4Endpoints", CIEXYZTRIPLE),
        ("bV4GammaRed", wintypes.DWORD),
        ("bV4GammaGreen", wintypes.DWORD),
        ("bV4GammaBlue", wintypes.DWORD),
    ]
#[repr(C)]
pub struct CIEXYZ {
    pub ciexyzX: i32,
    pub ciexyzY: i32,
    pub ciexyzZ: i32,
}

#[repr(C)]
pub struct CIEXYZTRIPLE {
    pub ciexyzRed: CIEXYZ,
    pub ciexyzGreen: CIEXYZ,
    pub ciexyzBlue: CIEXYZ,
}

#[repr(C)]
pub struct BITMAPV4HEADER {
    pub bV4Size: u32,
    pub bV4Width: i32,
    pub bV4Height: i32,
    pub bV4Planes: u16,
    pub bV4BitCount: u16,
    pub bV4V4Compression: u32,
    pub bV4SizeImage: u32,
    pub bV4XPelsPerMeter: i32,
    pub bV4YPelsPerMeter: i32,
    pub bV4ClrUsed: u32,
    pub bV4ClrImportant: u32,
    pub bV4RedMask: u32,
    pub bV4GreenMask: u32,
    pub bV4BlueMask: u32,
    pub bV4AlphaMask: u32,
    pub bV4CSType: u32,
    pub bV4Endpoints: CIEXYZTRIPLE,
    pub bV4GammaRed: u32,
    pub bV4GammaGreen: u32,
    pub bV4GammaBlue: u32,
}
import "golang.org/x/sys/windows"

type CIEXYZ struct {
	ciexyzX int32
	ciexyzY int32
	ciexyzZ int32
}

type CIEXYZTRIPLE struct {
	ciexyzRed CIEXYZ
	ciexyzGreen CIEXYZ
	ciexyzBlue CIEXYZ
}

type BITMAPV4HEADER struct {
	bV4Size uint32
	bV4Width int32
	bV4Height int32
	bV4Planes uint16
	bV4BitCount uint16
	bV4V4Compression uint32
	bV4SizeImage uint32
	bV4XPelsPerMeter int32
	bV4YPelsPerMeter int32
	bV4ClrUsed uint32
	bV4ClrImportant uint32
	bV4RedMask uint32
	bV4GreenMask uint32
	bV4BlueMask uint32
	bV4AlphaMask uint32
	bV4CSType uint32
	bV4Endpoints CIEXYZTRIPLE
	bV4GammaRed uint32
	bV4GammaGreen uint32
	bV4GammaBlue uint32
}
type
  CIEXYZ = record
    ciexyzX: Integer;
    ciexyzY: Integer;
    ciexyzZ: Integer;
  end;

  CIEXYZTRIPLE = record
    ciexyzRed: CIEXYZ;
    ciexyzGreen: CIEXYZ;
    ciexyzBlue: CIEXYZ;
  end;

  BITMAPV4HEADER = record
    bV4Size: DWORD;
    bV4Width: Integer;
    bV4Height: Integer;
    bV4Planes: Word;
    bV4BitCount: Word;
    bV4V4Compression: DWORD;
    bV4SizeImage: DWORD;
    bV4XPelsPerMeter: Integer;
    bV4YPelsPerMeter: Integer;
    bV4ClrUsed: DWORD;
    bV4ClrImportant: DWORD;
    bV4RedMask: DWORD;
    bV4GreenMask: DWORD;
    bV4BlueMask: DWORD;
    bV4AlphaMask: DWORD;
    bV4CSType: DWORD;
    bV4Endpoints: CIEXYZTRIPLE;
    bV4GammaRed: DWORD;
    bV4GammaGreen: DWORD;
    bV4GammaBlue: DWORD;
  end;
const CIEXYZ = extern struct {
    ciexyzX: i32,
    ciexyzY: i32,
    ciexyzZ: i32,
};

const CIEXYZTRIPLE = extern struct {
    ciexyzRed: CIEXYZ,
    ciexyzGreen: CIEXYZ,
    ciexyzBlue: CIEXYZ,
};

const BITMAPV4HEADER = extern struct {
    bV4Size: u32,
    bV4Width: i32,
    bV4Height: i32,
    bV4Planes: u16,
    bV4BitCount: u16,
    bV4V4Compression: u32,
    bV4SizeImage: u32,
    bV4XPelsPerMeter: i32,
    bV4YPelsPerMeter: i32,
    bV4ClrUsed: u32,
    bV4ClrImportant: u32,
    bV4RedMask: u32,
    bV4GreenMask: u32,
    bV4BlueMask: u32,
    bV4AlphaMask: u32,
    bV4CSType: u32,
    bV4Endpoints: CIEXYZTRIPLE,
    bV4GammaRed: u32,
    bV4GammaGreen: u32,
    bV4GammaBlue: u32,
};
type
  CIEXYZ {.bycopy.} = object
    ciexyzX: int32
    ciexyzY: int32
    ciexyzZ: int32

  CIEXYZTRIPLE {.bycopy.} = object
    ciexyzRed: CIEXYZ
    ciexyzGreen: CIEXYZ
    ciexyzBlue: CIEXYZ

  BITMAPV4HEADER {.bycopy.} = object
    bV4Size: uint32
    bV4Width: int32
    bV4Height: int32
    bV4Planes: uint16
    bV4BitCount: uint16
    bV4V4Compression: uint32
    bV4SizeImage: uint32
    bV4XPelsPerMeter: int32
    bV4YPelsPerMeter: int32
    bV4ClrUsed: uint32
    bV4ClrImportant: uint32
    bV4RedMask: uint32
    bV4GreenMask: uint32
    bV4BlueMask: uint32
    bV4AlphaMask: uint32
    bV4CSType: uint32
    bV4Endpoints: CIEXYZTRIPLE
    bV4GammaRed: uint32
    bV4GammaGreen: uint32
    bV4GammaBlue: uint32
struct CIEXYZ
{
    int ciexyzX;
    int ciexyzY;
    int ciexyzZ;
}

struct CIEXYZTRIPLE
{
    CIEXYZ ciexyzRed;
    CIEXYZ ciexyzGreen;
    CIEXYZ ciexyzBlue;
}

struct BITMAPV4HEADER
{
    uint bV4Size;
    int bV4Width;
    int bV4Height;
    ushort bV4Planes;
    ushort bV4BitCount;
    uint bV4V4Compression;
    uint bV4SizeImage;
    int bV4XPelsPerMeter;
    int bV4YPelsPerMeter;
    uint bV4ClrUsed;
    uint bV4ClrImportant;
    uint bV4RedMask;
    uint bV4GreenMask;
    uint bV4BlueMask;
    uint bV4AlphaMask;
    uint bV4CSType;
    CIEXYZTRIPLE bV4Endpoints;
    uint bV4GammaRed;
    uint bV4GammaGreen;
    uint bV4GammaBlue;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BITMAPV4HEADER サイズ: 108 バイト(x64)
dim st, 27    ; 4byte整数×27(構造体サイズ 108 / 4 切り上げ)
; bV4Size : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; bV4Width : INT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; bV4Height : INT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; bV4Planes : WORD (+12, 2byte)  wpoke st,12,値  /  値 = wpeek(st,12)
; bV4BitCount : WORD (+14, 2byte)  wpoke st,14,値  /  値 = wpeek(st,14)
; bV4V4Compression : BI_COMPRESSION (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; bV4SizeImage : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; bV4XPelsPerMeter : INT (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; bV4YPelsPerMeter : INT (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; bV4ClrUsed : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; bV4ClrImportant : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; bV4RedMask : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; bV4GreenMask : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; bV4BlueMask : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; bV4AlphaMask : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; bV4CSType : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; bV4Endpoints : CIEXYZTRIPLE (+60, 36byte)  varptr(st)+60 を基点に操作(36byte:入れ子/配列)
; bV4GammaRed : DWORD (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; bV4GammaGreen : DWORD (+100, 4byte)  st.25 = 値  /  値 = st.25   (lpoke/lpeek も可)
; bV4GammaBlue : DWORD (+104, 4byte)  st.26 = 値  /  値 = st.26   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global CIEXYZ
    #field int ciexyzX
    #field int ciexyzY
    #field int ciexyzZ
#endstruct

#defstruct global CIEXYZTRIPLE
    #field CIEXYZ ciexyzRed
    #field CIEXYZ ciexyzGreen
    #field CIEXYZ ciexyzBlue
#endstruct

#defstruct global BITMAPV4HEADER
    #field int bV4Size
    #field int bV4Width
    #field int bV4Height
    #field short bV4Planes
    #field short bV4BitCount
    #field int bV4V4Compression
    #field int bV4SizeImage
    #field int bV4XPelsPerMeter
    #field int bV4YPelsPerMeter
    #field int bV4ClrUsed
    #field int bV4ClrImportant
    #field int bV4RedMask
    #field int bV4GreenMask
    #field int bV4BlueMask
    #field int bV4AlphaMask
    #field int bV4CSType
    #field CIEXYZTRIPLE bV4Endpoints
    #field int bV4GammaRed
    #field int bV4GammaGreen
    #field int bV4GammaBlue
#endstruct

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