65 lines
2.3 KiB
C
65 lines
2.3 KiB
C
|
#ifndef PLOTBITMAP_H
|
|||
|
#define PLOTBITMAP_H
|
|||
|
|
|||
|
#include <QObject>
|
|||
|
#include <QPainter>
|
|||
|
#include <QBitmap>
|
|||
|
#include <QFile>
|
|||
|
//#include <gdiplus.h>
|
|||
|
|
|||
|
//BMP文件头(14字节)
|
|||
|
typedef struct /**** BMP file header structure ****/
|
|||
|
{
|
|||
|
unsigned short bfType; /* 类型 */
|
|||
|
unsigned int bfSize; /* 整个bmp文件大小 */
|
|||
|
unsigned short bfReserved1; /* Reserved */
|
|||
|
unsigned short bfReserved2; /* ... */
|
|||
|
unsigned int bfOffBits; /* 偏移数,位图文件头+位图信息头+调色板大小 */
|
|||
|
} BmpHeader;
|
|||
|
|
|||
|
//位图信息头(40字节)
|
|||
|
typedef struct /**** BMP file info structure ****/
|
|||
|
{
|
|||
|
unsigned int biSize; /* Size of info header */
|
|||
|
int biWidth; /* Width of image */
|
|||
|
int biHeight; /* Height of image */
|
|||
|
unsigned short biPlanes; /* Number of color planes */
|
|||
|
unsigned short biBitCount; /* Number of bits per pixel */
|
|||
|
unsigned int biCompression; /* Type of compression to use */
|
|||
|
unsigned int biSizeImage; /* Size of image data */
|
|||
|
int biXPelsPerMeter; /* X pixels per meter */
|
|||
|
int biYPelsPerMeter; /* Y pixels per meter */
|
|||
|
unsigned int biClrUsed; /* Number of colors used */
|
|||
|
unsigned int biClrImportant; /* Number of important colors */
|
|||
|
} BmpInfo;
|
|||
|
|
|||
|
class PlotBitmap : public QObject
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
public:
|
|||
|
explicit PlotBitmap(QObject *parent = NULL);
|
|||
|
|
|||
|
public:
|
|||
|
//创建单色的位图
|
|||
|
//输入参数:
|
|||
|
// bTransparent 透明显示
|
|||
|
// crBkColor 背景颜色(在透明显示时位图中颜色为crBkColor的点将不被显示在纸样上)
|
|||
|
// iWidth 位图的宽,单位:像素
|
|||
|
// iHeight 位图的高,单位:像素
|
|||
|
// iStride 位图每行的字节数
|
|||
|
// nPixFormat 位图点的格式(见GDI+中BitmapData类PixelFormat的定义)
|
|||
|
// pBmpData 位图数据(保存数据的顺序是从左到右,从上到下)
|
|||
|
//返回值:
|
|||
|
// NULL 失败
|
|||
|
// 非NULL 新生成的位图指针
|
|||
|
//QBitmap Create1BPPBitmap(int bTransparent,int crBkColor,int iWidth,int iHeight,int iStride,int nPixFormat,char *pBmpData);
|
|||
|
QBitmap Create1BPPBitmap(int iWidth,int iHeight,unsigned char *pBmpData);
|
|||
|
|
|||
|
void SetUncharBit(unsigned char & dat, int index, int val);
|
|||
|
signals:
|
|||
|
|
|||
|
public slots:
|
|||
|
};
|
|||
|
|
|||
|
#endif // PLOTBITMAP_H
|