graphic.c

来自「好记星的控件,包括button,list,对文件操作」· C语言 代码 · 共 1,483 行 · 第 1/5 页

C
1,483
字号
/****************************************************************************/
/* FUNCTION:   GraphicInitialize                                            */
/* DESCRIPTION:Graphic Module initialization                               */
/* INPUTS:     uInitMode   Initial state                                   */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     This function initialization the global variant on reset    */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse       2002-08-11     build                                        */
/*   谢永良     2003-08-07     任何情况下的模块初始化都需要初始化全局变量   */
/****************************************************************************/
BOOL GraphicInitialize(VOID)
{
//  UINT32 dwColor, dwBKColor;
	if(g_bLcdAlreadyInitFlag == TRUE)
		return TRUE;
	g_bLcdAlreadyInitFlag = TRUE;
	if (!GraphSetActiveLcd(0))                       /*Set default Lcd active*/
        {
            return FALSE;
        }	
	g_GraphRefreshFlag = 0;                                         //Screen refresh flag
    g_bFillFade = FALSE;
    g_dwTransparentColor = 0xffffffff;                              //默认白色透明

    g_mTable.dwBKColor = WHITE;
    g_mTable.dwColor = BLACK;
    g_mTable.style = DRMODE_SRCCOPY;

#if   COLOR_LEVEL >= 4     
    g_mTable.pCurTable = (UINT32 *)&Std1To4;
#if 0
				dwColor = WHITE ;
				dwBKColor = BLACK; 
				{
					
					UINT32  *pTmpDst, *pSrc;
					int     i;
					
					g_mTable.pCurTable = (UINT32 *)&g_mTable.table;
					pTmpDst = g_mTable.pCurTable;
					pSrc = (UINT32 *)&Std1To4;
					dwColor = (~dwColor & 0xffffff);
					dwColor |= dwColor << 8;
					dwBKColor = (~dwBKColor & 0xffffff);
					dwBKColor |= dwBKColor << 8;
					for (i = 0; i < 256; ++ i) {
						*pTmpDst = pSrc[i] & dwColor | (~pSrc[i] & dwBKColor);
						pTmpDst ++;
					}

				}
#endif
					
#endif
    return TRUE;
}
/****************************************************************************/
/* FUNCTION:   GraphGetSystemDC                                             */
/* DESCRIPTION:GET system default DC.                       */
/* INPUTS:     ,DC pointer for destine DC                               */
/* OUTPUTS:    pDc point to the system DC                                 */
/* RETURN:     TRUE if successful                                          */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*                                          */
/****************************************************************************/

MDC* GraphGetSystemDC( VOID)
{
/*
	if( pDC )
	{
		pDC	= &g_dcSystemDC;
		return TRUE;
	}
*/
	return &g_dcSystemDC;
}
/****************************************************************************/
/* FUNCTION:   GraphInitialDC                                             */
/* DESCRIPTION:Initialize DC with system default DC.                       */
/* INPUTS:     ,DC pointer for destine DC                               */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse       2002-08-11     build                                        */
/****************************************************************************/
VOID GraphInitialDC( VOID )
{
	memmove((UINT8*)&g_dcSystemDC, (UINT8*)GraphicDefaultDC, sizeof(MDC));    /*Initialize DC with default system dc information*/
        g_dcSystemDC.dcBitMapInfo = (MBitMapInfo*)GRAPHIC_DISP_BUFFER;               /*Set Screen video buffer*/
       
		g_dcSystemDC.dcBKColor = RGB( 0XFF,0XFF,0XFF);
        g_dcSystemDC.dcBrush.bsColor = RGB( 0Xff,0Xff,0Xff);
        g_dcSystemDC.dcFontID = SYSTLIB;
        g_dcSystemDC.dcPen.pnColor = RGB( 0,0,0 );
        g_dcSystemDC.dcTextColor = RGB( 0,0,0 );
		/*
        g_dcSystemDC.dcBKColor = g_mGuiSetting.guiUsrBKColor;
        g_dcSystemDC.dcBrush.bsColor = g_mGuiSetting.guiSysSolidBKLtColor;
        g_dcSystemDC.dcFontID = g_mGuiSetting.guiSysFontID;
        g_dcSystemDC.dcPen.pnColor = g_mGuiSetting.guiSysLineColor;
        g_dcSystemDC.dcTextColor = g_mGuiSetting.guiSysTextColor;
*/  
}

/****************************************************************************/
/* FUNCTION:   __GraphCreateBitMapInfo                                     */
/* DESCRIPTION:Create compatible BitMap information with destine DC.       */
/* INPUTS:     ,DC pointer for destine DC                               */
/*              pBitMapInfo,bitmap information buffer pointer.              */
/*              iWidth,the area width.                                      */
/*              iHeight,the area height.                                    */
/* OUTPUTS:    pBitMapInfo                                                 */
/* RETURN:     Null on error.                                              */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse       2002-08-11     build                                        */
/****************************************************************************/

 MBitMapInfo *__GraphCreateBitMapInfo(MBitMapInfo *pBitMapInfo,UINT iWidth,UINT iHeight)
{    

	UINT32  bmpBuffSize, dwPalleteSize; //Buffer size for pBitMapInfo
    UINT    colorbit;
    MBitMapInfo			*pRetBitMap;             //Return value
    MBitMapInfoHeader	*headinfo;         //BitMap head information    
    // Check the destine pDC
    pRetBitMap = NULL;
    headinfo = &(g_dcSystemDC.dcBitMapInfo->bmpInfo);
    colorbit = headinfo->biBitCount;
    bmpBuffSize = _getLineBytes(colorbit, iWidth);
    dwPalleteSize = _getPaletteSize(colorbit, headinfo->biClrUsed);
    bmpBuffSize *= iHeight;
    
    // No valid buffer provided by user
    if (!pBitMapInfo)
    {
        pBitMapInfo = (MBitMapInfo *)MemAlloc(bmpBuffSize
            + sizeof(MBitMapInfoHeader) + dwPalleteSize);
    }
    
    // Get valid buffer
    if (pBitMapInfo)
    {
        UINT32  dwHeadLength;
        UINT8   *pClearBuff;
        
        dwHeadLength = sizeof(MBitMapInfoHeader) + dwPalleteSize;
        memmove((UINT8*)pBitMapInfo, (UINT8*)headinfo, dwHeadLength);
        
        // Get the position of new bitmap
        headinfo = &(pBitMapInfo->bmpInfo);
        headinfo->biWidth = iWidth;
        headinfo->biHeight = iHeight;
		
        // Buffer beginning address
        pClearBuff = (UINT8*)pBitMapInfo + dwHeadLength;
        
        // Initialize new bitmap data area with filling oxff
        memset(pClearBuff, 0xff, bmpBuffSize);
		
        pRetBitMap = pBitMapInfo;
    }
    
    return pRetBitMap;
	
}

/****************************************************************************/
/* FUNCTION:   GraphCreateBitMapInfo                                      */
/* DESCRIPTION:Create compatible BitMap information with system  DC.       */
/* INPUTS:     pBitMapInfo,bitmap information buffer pointer.              */
/*              iWidth,the area width.                                      */
/*              iHeight,the area height.                                    */
/* OUTPUTS:    pBitMapInfo                                                 */
/* RETURN:     Null on error.                                              */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse       2002-08-11     build                                        */
/****************************************************************************/
MBitMapInfo *GraphCreateBitMapInfo(MBitMapInfo *pBitMapInfo,UINT iWidth,UINT iHeight)
{
    //Create compatible BitMap information with g_dcSystemDC
    return __GraphCreateBitMapInfo(pBitMapInfo,iWidth,iHeight);
}

/****************************************************************************/
/* FUNCTION:   GraphSetPen                                                */
/* DESCRIPTION:Reset Pen for destine  DC.                                  */
/* INPUTS:     ,destion DC pointer.                                     */
/*              pPen,new source Pen pointer.                                */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse       2002-08-11     build                                        */
/****************************************************************************/
/*VOID GraphSetPen(MPen* pPen)
{
    if (!pPen)                                                      //heck if the new pen is valid
    {
        return;
    }
    memmove((UINT8*)&(g_dcSystemDC.dcPen),(UINT8*)pPen,sizeof(MPen));       //he new pen become effective
}
*/
UINT32   GraphSetPenColor(UINT32 dwColor)
{	
    UINT32  dwOldColor;

    dwOldColor = g_dcSystemDC.dcPen.pnColor;
    if (_IsSystemColor(dwColor & 0xffffff)) {
        g_dcSystemDC.dcPen.pnColor = dwColor & 0xffffff;
    }
    return dwOldColor;	
}
UINT32   GraphGetPenColor(VOID)
{
    return g_dcSystemDC.dcPen.pnColor ;	
}
UINT16			GraphGetPenStyle( VOID)
{
    return g_dcSystemDC.dcPen.pnStyle ;	
	
}
UINT16			GraphSetPenStyle( UINT16 wPenStyle)
{
	UINT16	wOldStyle;
     wOldStyle = g_dcSystemDC.dcPen.pnStyle ;
	 g_dcSystemDC.dcPen.pnStyle = wPenStyle;
	 return wOldStyle;
	
}

/****************************************************************************/
/* FUNCTION:   _GraphgetPen                                                */
/* DESCRIPTION:Get Pen for destine  DC.                                    */
/* INPUTS:     ,destion DC pointer.                                     */
/*              pPen,destine Pen pointer to output Pen information.         */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse       2002-08-11     build                                        */
/****************************************************************************/
/*ID GraphGetPen(MPen *pPen)
{
    if (!pPen)                                                      //Check if the brush buffer is valid
    {
        return;
    }
    memmove((UINT8*)pPen,(UINT8*)&(g_dcSystemDC.dcPen),sizeof(MPen));       //Copy the pen information
}
*/
/****************************************************************************/
/* FUNCTION:   GraphSetBrush                                              */
/* DESCRIPTION:Reset Brush for destine  DC.                                */
/* INPUTS:     ,destion DC pointer.                                     */
/*              pBrush,new source Brush pointer.                            */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse       2002-08-11     build                                        */
/****************************************************************************/
/*
VOID GraphSetBrush(MBrush *pBrush)
{
    if (!pBrush)                                                    //Check if the new brush is valid
    {
        return;
    }
    memmove((UINT8*)&(g_dcSystemDC.dcBrush),(UINT8*)pBrush,sizeof(MBrush)); //The new brush become effective  
}
*/
UINT32   GraphSetBrushColor(UINT32 dwColor)
{
	    UINT32  dwOldColor;
    dwOldColor = g_dcSystemDC.dcBrush.bsColor;
    if (_IsSystemColor(dwColor & 0xffffff)) {
        g_dcSystemDC.dcBrush.bsColor = dwColor & 0xffffff;
    }
    return dwOldColor;	

}
UINT32   GraphGetBrushColor(VOID)

⌨️ 快捷键说明

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