Files
template/image_proc.h
T

28 lines
854 B
C
Raw Normal View History

2026-09-13 20:57:03 +08:00
#ifndef IMAGE_PROC_H
#define IMAGE_PROC_H
#include <stdint.h>
#include <windows.h>
typedef struct {
int width;
int height;
int stride; // 连续灰度数据每行字节数 (无 4 字节对齐,= width)
uint8_t *data; // 连续内存 (height * width)
uint8_t **rows; // 行指针 (rows[0] 顶行)
} GrayImage;
// 从已加载的 BMP 像素提取灰度 (支持 8/24/32 bpp),源为 bottom-up DIB,输出 top-down
// srcPixels: 原始像素 (bottom-up)
// bpp: 8 / 24 / 32
// 返回 1 成功 0 失败
int ExtractGray(const uint8_t *srcPixels, int w, int h, int bpp, GrayImage *outImg);
// 释放
void FreeGray(GrayImage *img);
// 把灰度图转换成可直接 StretchDIBits 的 8 位 DIB (bottom-up + 调色板)
// 返回 1 成功
int Build8BitDIB(const GrayImage *img, BITMAPINFO **outBMI, uint8_t **outPixels);
#endif