找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 3174|回复: 1

【C】BitmapInfoHeader等结构体的可移植声明

[复制链接]

1111

主题

1651

回帖

7万

积分

用户组: 管理员

一只技术宅

UID
1
精华
244
威望
743 点
宅币
24235 个
贡献
46222 次
宅之契约
0 份
在线时间
2296 小时
注册时间
2014-1-26
发表于 2015-4-5 01:52:59 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
这些代码用于操作BMP文件。这些代码是跨平台的。能在不同的平台完成编译。
为了和Windows自带的结构体区分开来,我改变了大小写。
  1. #include<stdint.h>

  2. #pragma pack(push,1)

  3. typedef struct
  4. {
  5.         uint16_t        bfType;
  6.         uint32_t        bfSize;
  7.         uint16_t        bfReserved1;
  8.         uint16_t        bfReserved2;
  9.         uint32_t        bfOffBits;
  10. }BitmapFileHeader,*BitmapFileHeaderP;

  11. typedef struct
  12. {
  13.         uint32_t        biSize;
  14.         int32_t                biWidth;
  15.         int32_t                biHeight;
  16.         uint16_t        biPlanes;
  17.         uint16_t        biBitCount;
  18.         uint32_t        biCompression;
  19.         uint32_t        biSizeImage;
  20.         int32_t                biXPelsPerMeter;
  21.         int32_t                biYPelsPerMeter;
  22.         uint32_t        biClrUsed;
  23.         uint32_t        biClrImportant;
  24. }BitmapInfoHeader,*BitmapInfoHeaderP;

  25. typedef struct
  26. {
  27.         uint8_t        B;
  28.         uint8_t        G;
  29.         uint8_t        R;
  30.         uint8_t        X;
  31. }RGBQuad,*RGBQuadP;

  32. typedef struct
  33. {
  34.         BitmapInfoHeader bmiHeader;
  35.         RGBQuad          bmiColors[1];
  36. }BitmapInfo,*BitmapInfoP;

  37. #pragma pack(pop)
复制代码

本帖被以下淘专辑推荐:

回复

使用道具 举报

1111

主题

1651

回帖

7万

积分

用户组: 管理员

一只技术宅

UID
1
精华
244
威望
743 点
宅币
24235 个
贡献
46222 次
宅之契约
0 份
在线时间
2296 小时
注册时间
2014-1-26
 楼主| 发表于 2015-4-5 01:53:38 | 显示全部楼层
为什么要跨平台?为了不让自己写过的代码随着时间老去!
回复 赞! 靠!

使用道具 举报

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-4-20 10:32 , Processed in 0.039237 second(s), 34 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表