⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphic.h

📁 好记星的控件,包括button,list,对文件操作
💻 H
字号:
/****************************************************************************/
/*                                                                          */
/*              Copyright (C) 2002 SHENZHEN MEIJIN CO.LTD                   */
/*                                                                          */
/* FILE NAME:   Graphic.h                                                   */
/* MODULE NAME: Graphic                                                     */
/* DESCRIPTION: Graphic module head file.                                   */
/*                                                                          */
/****************************************************************************/
/*    DTAE       AUTHOR     VERSION                 REMARKS                 */
/* =========== ==========  =========  ======================================*/
/* 2002-08-11     Qorse    Ver 1.00   Build                                 */
/* 2003-06-13   谢永良     删除函数ID号和模块调用                           */
/****************************************************************************/

/* To prenvt this file to be overloaded */
#ifndef __GRAPHIC_H__
#define __GRAPHIC_H__

#include "..\..\Kernel\Graphic\Graphic2.h"
//#include "..\..\Kernel\Graphic\graphin.h"

//for bmp->compression
#define BI_RGB			0 // An uncompressed format.
#define BI_RLE4			1 // RLE 4-bit		
#define	BI_RLE8			2 // RLE 8-bit		
#define BI_BITFIELDS	3 // Bitfields(565)	

//#define RGB(r, g, b)    (UINT32)((r>0 || g>0 ||b>0)?1:0)

#define RGB(r, g, b)    (UINT32)((UINT8)r | ((UINT8)g << 8) |((UINT8)b << 16))


//#define MAKE_16BIT_COLOR(r, g, b) ( (b>>3) + (((UINT16)(g & 0xfc))<<3) + (((UINT16)(r & 0xf8))<<8) )
#define MAKE_16BIT_COLOR(r, g, b)  RGB(r, g, b)
#define GRGB16(r,g,b)(UINT32)(						\
			((((UINT16)(r)) & 0xF8 ) << 8) |		\
			((((UINT16)(g)) & 0xFC ) << 3) |		\
			((((UINT16)(b)) & 0xF8 )	>> 3)		\
		)
#define GRGB12(r,g,b)(UINT32)(						\
			((((UINT16)(r)) & 0xF0 ) << 4)  |		\
			(((UINT16)(g)) & 0xF0 )         |		\
			((((UINT16)(b)) & 0xF0 )	>> 4)		\
		)


#define LCD_GRAYLVL_1		1	/*1 BIT, 2 GRAY LEVEL*/
#define LCD_GRAYLVL_2		2	/*2 BIT, 4 GRAY LEVEL*/
#define LCD_GRAYLVL_4		4	/*4 BIT,16 GRAY LEVEL*/
#define LCD_GRAYLVL_8		8	/*256色*/
#define LCD_GRAYLVL_16		16	/*16位高彩色*/
#define LCD_GRAYLVL_24		24	/*24位真彩色*/
#define LCD_GRAYLVL_32		32	/*32位真彩色*/

#define MBMPFHEADERSIZE 14
#define COLOR_LEVEL 1
#define DEFAULT_COLOR_LEVEL 1
#define BLACK               RGB(0X00,0X00,0X00)
#define WHITE               RGB(0XFF,0XFF,0XFF)
#define TRANSPARENT_COLOR	0x410	

//程序设置画笔,画刷,文本,背景颜色是必须指定下列之一,否则设置不成功!

//以下供系统,应用程序使用
#define BLACK_COLOR             0
#define WHITE_COLOR             WHITE

//以下只供系统使用,应用程序不准使用
#define GRAYCOLOR_BLACK			BLACK
#define GRAYCOLOR_WHITE			RGB(0XFF,0XFF,0XFF)
#define GRAYCOLOR_GRAY			GRAYCOLOR_LEVEL_8
#define GRAYCOLOR_LEVEL_1		RGB(0X11,0X11,0X11)
#define GRAYCOLOR_LEVEL_2		RGB(0X22,0X22,0X22)
#define GRAYCOLOR_LEVEL_3		RGB(0X33,0X33,0X33)
#define GRAYCOLOR_LEVEL_4		RGB(0X44,0X44,0X44)
#define GRAYCOLOR_LEVEL_5		RGB(0X55,0X55,0X55)
#define GRAYCOLOR_LEVEL_6		RGB(0X66,0X66,0X66)
#define GRAYCOLOR_LEVEL_7		RGB(0X77,0X77,0X77)
#define GRAYCOLOR_LEVEL_8		RGB(0X88,0X88,0X88)
#define GRAYCOLOR_LEVEL_9		RGB(0X99,0X99,0X99)
#define GRAYCOLOR_LEVEL_A		RGB(0XAA,0XAA,0XAA)
#define GRAYCOLOR_LEVEL_B		RGB(0XBB,0XBB,0XBB)
#define GRAYCOLOR_LEVEL_C		RGB(0XCC,0XCC,0XCC)
#define GRAYCOLOR_LEVEL_D		RGB(0XDD,0XDD,0XDD)
#define GRAYCOLOR_LEVEL_E		RGB(0XEE,0XEE,0XEE)
#define GRAYCOLOR_LEVEL_F		GRAYCOLOR_WHITE
/*****************************************************************************/
/* GRAPHIC                                                                   */
/*****************************************************************************/
/* Macro definition*/

/* Pen Style*/
#define PS_SOLID            0       /* Solid line       */
#define PS_DASH             1       /* Dash line        */
#define PS_DOT              2       /* dot line         */
#define PS_DASHDOT          3       /* Dash dot line    */
#define PS_DASHDOTDOT       4       /* Dash dot dot line*/
#define PS_DOT_SPACE        5       /* Dash dot with 2 dots jump*/

/* Font Style*/
#define FS_NORMAL           0x00       /* Normal font      */
//#define FS_UNDERLINE        0x01       /* Under-line font  */
//#define FS_MIDDLELINE       0x02       /* Middle-line font */
//#define FS_BOLD             0x04       /* BOLD font        */
//#define FS_ITALIC           0x08       /* Italic font      */

/* Hatch style(be efficient while Brush style is BS_HATCHED)*/
#define HS_HORIZONTAL       0       /* ----- */
#define HS_VERTICAL         1       /* ||||| */
#define HS_FDIAGONAL        2       /* \\\\\ */
#define HS_BDIAGONAL        3       /* ///// */
#define HS_CROSS            4       /* +++++ */
#define HS_DIAGCROSS        5       /* xxxxx */

/* Brush style*/
#define BS_SOLID            0       /* Solid brush  */
#define BS_NULL             1       /* No brush     */
#define BS_HATCHED          2       /* Hatch brush  */
//#define BS_PATTERN          3       /* Pattern brush*/
//#define BS_DIBPATTERN       4       /* Bitmap brush (not larger than 8*8 on size) */
//#define BS_DIBPATTERNPT     5       /* Bitmap brush (no size limitation) */
/*The following style are used to fade a area from brush color to background color*/
//#define BS_SOLID_VFADE		            6   /* Up to Down*/
//#define BS_SOLID_HFADE		            7   /* Left to Right*/
//#define BS_SOLID_VFADE_DOWN2UP		    8   /* Down to UP*/
//#define BS_SOLID_HFADE_RIGHT2LEFT	    9   /* Right to Left*/
//#define BS_SOLID_VFADE_CENTER2BORDER	10  /* Center to Up-Down border*/
//#define BS_SOLID_HFADE_CENTER2BORDER	11  /* Center to Left-Right border*/

/*Draw Mode*/
#define DRMODE_SRCCOPY      0       /* dest = source                */
#define DRMODE_SRCOR        1       /* dest = source OR dest        */
#define DRMODE_SRCAND       2       /* dest = source AND dest       */
//#define DRMODE_SRCXOR       3       /* dest = source XOR dest       */
//#define DRMODE_SRCANDNOT    4       /* dest = source AND(NOT dest ) */
#define DRMODE_NOTSRC       5       /* dest =(NOT source)           */
#define DRMODE_SRCSHADOW    6       /* dest =(source & 0x55)        */
#define DRMODE_DSTSHADOW    7       /* dest =(DST & 0x55)           */
//#define DRMODE_NOTSRCANDNOT 8       /* dest =(NOT src) AND(NOT dest)*/
//#define DRMODE_NOTSRCOR     9       /* dest =(NOT source) OR dest   */
//#define DRMODE_NOTDST       10      /* dest =(NOT dest)             */
//#define DRMODE_BLACKNESS    11      /* dest = BLACK                 */
//#define DRMODE_WHITENESS    12      /* dest = WHITE                 */
#define DRMODE_FADE         13      /* dest fade                    */
#define DRMODE_TRANSPARENT  14      /* transparent effect           */
//#define DRMODE_TRANSPARENT_FADE  15 /* fade with transparent effect */

/*系统支持的图形格式*/
#define IMAGE_FILE_TYPES	4
#define IMAGE_FILE_BMP		0x0000
#define IMAGE_FILE_GIF		0x0001
#define IMAGE_FILE_JPG		0x0002
#define IMAGE_FILE_PCX		0x0003

#define IMAGE_MEM_BMP		0x8000
#define IMAGE_MEM_GIF		0x8001
#define IMAGE_MEM_JPG		0x8002
#define IMAGE_MEM_PCX		0x8003

/*******************************************/
// 谢永良增加下面的宏(从Guibasic.h中移过来)
#define OF_BOUND_STYLE      0x03
#define OF_ALIGN_STYLE      0x03
/* 风格定义 */
//#define OF_BOUND_POP            0x00
#define OF_BOUND_FLAT           0x01
#define OF_BOUND_FRAME          0x02
#define OF_BOUND_SHADOW         0x03

#define OF_ALIGN_CENTER     0x00
#define OF_ALIGN_LEFT       0x01
#define OF_ALIGN_RIGHT      0x02
/*******************************************/


/*data type define*/
/*******************************************/
// 谢永良从OsBase.h中移来下面的宏定义
/* 区域结构定义 */
typedef struct tagMRect{
    UINT16  x;
    UINT16  y;
    UINT16  width;
    UINT16  height;
}MRect;
/*******************************************/

typedef struct tagMRGBQUAD
{
    UINT8       rgbBlue;            /* Blue element     */
    UINT8       rgbGreen;           /* Green element    */
    UINT8       rgbRed;             /* Red element      */
    UINT8       rgbReserved;        /* Reserved         */
} MRGBQUAD;

typedef struct tagPOINTSTRUCT
{
    INT32       x;
    INT32       y;
} MPoint;

typedef struct tagPEN
{
    UINT16      pnStyle;            /* Line style           */
    MPoint      pnWidth;            /* Line Width(X is efficient and Y is reserved)*/
    UINT32      pnColor;            /* Pen color index      */
} MPen;

typedef struct  tagBRUSH
{
   UINT16       bsStyle;            /* Brush style */
   UINT32       bsColor;            /* Brush color */
   UINT32       bsHatch;            /* Hatch style or pattern pointer*/
} MBrush;

typedef struct tagPaletteType
{
    UINT32      ptCount;
    MRGBQUAD    ptColors[1];
} MPaletteType;

typedef struct tagMBitMapFILEHEADER
{
    UINT16          bfType;         /* BMP file flag    */
    UINT32          bfSize;         /* File size        */
    UINT16          bfReserved1;    /* Reserved         */
    UINT16          bfReserved2;    /* Reserved         */
    UINT32          bfOffBits;      /* Offset bytes to data */
} MBitMapFileHeader;

typedef struct tagMBitMapINFOHEADER
{
    UINT32          biSize;         /* Structure length */
//    UINT32          biWidth;        /* Bitmap width     */
//    UINT32          biHeight;       /* Bitmap height    */
    INT32           biWidth;        /* Bitmap width     */
    INT32           biHeight;       /* Bitmap height    */
    UINT16          biPlanes;       /* Bitmap planes    */
    UINT16          biBitCount;     /* Bits to describe a color information */
    UINT32          biCompression;  /* Compress flag    */
    UINT32          biSizeImage;    /* Data size before compress */
    UINT32          biXPelsPerMeter;/* Horizontal       */
    UINT32          biYPelsPerMeter;/* Vertical         */
    UINT32          biClrUsed;      /* Color used in pallete */
    UINT32          biClrImportant; /* Important color  */
} MBitMapInfoHeader,MBitMap;

typedef struct tagBITMAPINFOSTRUCT
{
    MBitMap     bmpInfo;
    MRGBQUAD    bmpColors[1];       /* Data of color,include pallete and color index */
} MBitMapInfo;

typedef struct tagDeviceContext
{
    INT             dcX;            /* X-cordinate                      */
    INT             dcY;            /* Y-cordinate                      */
    UINT            dcWidth;        /* The width mapped to screen       */
    UINT            dcHeight;       /* The height mapped to screen      */
    MPen            dcPen;          /* Pen information                  */
    MBrush          dcBrush;        /* Brush information                */
    UINT32          dcTextColor;    /* Text color                       */
    UINT32          dcBKColor;      /* Background color                 */

	UINT8           dcDrawMode;     /* Draw mode                        */
    UINT16          dcFontStyle;    /* Font library ID                  */
    UINT16          dcFontID;       /* Font library ID                  */
	MBitMapInfo*     dcBitMapInfo;   /* The bitmap information,include bitmap struct ,palette ,and color information,
									and point to System DC BitMapInfo struct in default*/
/*									
    MPaletteType*   dcPallete;      //* Pallete struct pointer,reserved  
    UINT16          dcDrawMode;     //* Draw mode                        
    UINT16          dcFontID;       //* Font library ID                  
    MBitMapInfo*    dcBitMapInfo;   //* The bitmap information,include bitmap struct ,pallete ,and color information,
                                     //  and point to System DC BitMapInfo struct in default
*/
} MDC;


/* Function declaration */
/* Module initial function, 1 */
BOOL            GraphicInitialize(VOID);
//pen
UINT16			GraphGetPenStyle( VOID);
UINT16			GraphSetPenStyle( UINT16 wPenStyle);
//brush
UINT16			GraphGetBrushStyle(VOID);
UINT16			GraphSetBrushStyle(UINT16 wBrushStyle);
UINT32			GraphGetBrushHatchStyle(VOID);
UINT32			GraphSetBrushHatchStyle(UINT32 wBrushHatchStyle);
UINT32			GraphSetBrushColor(UINT32 dwColor);
UINT32			GraphGetBrushColor(VOID);
//background color
UINT32          GraphSetBKColor(UINT32 dwColor);
UINT32          GraphGetBKColor(VOID);
//pen  color
UINT32			GraphSetPenColor(UINT32 dwColor);
UINT32			GraphGetPenColor(VOID);
//Text color
UINT32          GraphSetTextColor(UINT32 dwColor);
UINT32          GraphGetTextColor(VOID);
//draw mode
UINT8			GraphSetDrawMode(UINT8 uDrawMode);
UINT8			GraphGetDrawMode(VOID);

/* Drawing function, 4 */
VOID            GraphDrawDot(INT x,INT y);
VOID            GraphDrawLine(INT x1,INT y1,INT x2,INT y2);
VOID            GraphDrawRect(INT x1,INT y1,INT x2,INT y2);
/* Function about bitmap */
//创建位图信息(若指针为空,则用指定的宽度,高度创建一个BMP图所占用大小的内存),并用系统DC格式化位图信息头
MBitMapInfo		*GraphCreateBitMapInfo(MBitMapInfo *pBitMapInfo,UINT iWidth,UINT iHeight);
VOID            GraphDrawIcon(INT x,INT y,UINT width,UINT height,UINT8 *lpRes);

//MBitMapInfo*    GraphLoadBitMap(UINT8 *pFileName,UINT8 *buffer,UINT32 *BufferSize);
//MBitMapInfo*    GraphGetFileFrame(UINT8 *pFileName,UINT8 *buffer,UINT32 *BufferSize,UINT dwFrame);
/*Function about text echo */
VOID            GraphDrawText(INT x,INT y,UINT uWidth,UINT uHeight,UINT8 *lpRes);
/* Function about area operation */
VOID            GraphFillRect(INT x1,INT y1,INT x2,INT y2);
VOID            GraphClearRect(INT x1,INT y1,INT x2,INT y2);
VOID            GraphInvertRect(INT x1,INT y1,INT x2,INT y2);
/* Append function */
VOID            GraphClearScreen();
VOID            GraphDrawBorder(INT x, INT y, UINT width, UINT height, UINT style);
VOID            GraphDrawAlignText(INT x, INT y, UINT uWidth, UINT uHeight, UINT8* strAddr, UINT site);
VOID            GraphDrawWrapText(INT x, INT y, UINT uWidth, UINT uHeight, UINT8* strAddr);

VOID            GraphEnableRefresh();
VOID            GraphDisableRefresh();
UINT            GraphGetScreenWidth();
UINT            GraphGetScreenHeight();
BOOL            GraphGetIconSize(UINT *width,UINT *height,UINT8 *lpRes);
MDC*			GraphGetSystemDC( VOID);
VOID            GraphDotRect(INT x1,INT y1,INT x2,INT y2);

//字体,added by Liang Ruhui
UINT16          GraphSetFontID(UINT16 wFontID);
UINT16          GraphGetFontID(VOID);
UINT16          GraphSetFontStyle(UINT16);
UINT16          GraphGetFontStyle(VOID);
UINT16          GraphSetFontInvertStyle(VOID);
UINT16          GraphClearFontInvertStyle(VOID);
UINT16          GraphSetFontUnderlineStyle(VOID);
UINT16          GraphClearFontUnderlineStyle(VOID);

#endif  /* #ifndef __GRAPHIC_H__ */




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -