void GUI_DrawBitmapExp(int x0, int y0, int XSize, int YSize, int XMul, int YMul, int BitsPerPixel, int BytesPerLine, const U8* pData, const GUI_LOGPALETTE* pPal) { GUI_DRAWMODE PrevDraw; GUI_LOCK(); PrevDraw = GUI_SetDrawMode((pPal && pPal->HasTrans) ? GUI_DRAWMODE_TRANS : 0); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); { GUI_RECT r; r.x0 = x0; r.x1 = x0 + XSize * XMul -1; r.y0 = y0; r.y1 = y0 + YSize * YMul -1; WM_ITERATE_START(&r); { #endif LCD_DrawBitmap( x0, y0 ,XSize ,YSize, XMul, YMul ,BitsPerPixel, BytesPerLine, pData, pPal); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); } #endif GUI_SetDrawMode(PrevDraw); GUI_UNLOCK(); }
//-------------------------------------------------------------------------------------------------- // Name: Demo Functions // Function: // // Parameter: // Return: //-------------------------------------------------------------------------------------------------- void DemoLogo(void) { LCD_ClearScreen(); LCD_DrawBitmap(0,0,bmp_raspi); LCD_SetFont(0); LCD_PrintXY(70,4 ,"Raspi-LCD"); LCD_PrintXY(75,14,"Project"); LCD_PrintXY(68,32,"powered by"); LCD_PrintXY(70,42,"Emsystech"); LCD_PrintXY(62,52,"Engineering"); }
/********************************************************************* * * GUIPROP_DispChar * * Purpose: * This is the routine that displays a character. It is used by all * other routines which display characters as a subroutine. */ void GUIPROP_DispChar(U16P c) { int BytesPerLine; GUI_DRAWMODE DrawMode = GUI_Context.TextMode; const GUI_FONT_PROP GUI_UNI_PTR * pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c); if (pProp) { GUI_DRAWMODE OldDrawMode; const GUI_CHARINFO GUI_UNI_PTR * pCharInfo = pProp->paCharInfo+(c-pProp->First); BytesPerLine = pCharInfo->BytesPerLine; OldDrawMode = LCD_SetDrawMode(DrawMode); if (GUI_MoveRTL) { GUI_Context.DispPosX -= pCharInfo->XDist * GUI_Context.pAFont->XMag; } LCD_DrawBitmap( GUI_Context.DispPosX, GUI_Context.DispPosY, pCharInfo->XSize, GUI_Context.pAFont->YSize, GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag, 1, /* Bits per Pixel */ BytesPerLine, pCharInfo->pData, &LCD_BKCOLORINDEX ); /* Fill empty pixel lines */ if (GUI_Context.pAFont->YDist > GUI_Context.pAFont->YSize) { int YMag = GUI_Context.pAFont->YMag; int YDist = GUI_Context.pAFont->YDist * YMag; int YSize = GUI_Context.pAFont->YSize * YMag; if (DrawMode != LCD_DRAWMODE_TRANS) { LCD_COLOR OldColor = GUI_GetColor(); GUI_SetColor(GUI_GetBkColor()); LCD_FillRect(GUI_Context.DispPosX, GUI_Context.DispPosY + YSize, GUI_Context.DispPosX + pCharInfo->XSize, GUI_Context.DispPosY + YDist); GUI_SetColor(OldColor); } } LCD_SetDrawMode(OldDrawMode); /* Restore draw mode */ if (!GUI_MoveRTL) { GUI_Context.DispPosX += pCharInfo->XDist * GUI_Context.pAFont->XMag; } } }
/********************************************************************* * * GUI_SIF_DispChar */ static void _GUI_SIF_DispChar(U16P c) { const U8 * pCharInfo, * pData; pCharInfo = _GetpCharInfo(GUI_Context.pAFont, c); if (pCharInfo) { GUI_DRAWMODE DrawMode, OldDrawMode; GUI_SIF_CHARINFO CharInfo; CharInfo.XSize = GUI__Read16(&pCharInfo); CharInfo.XDist = GUI__Read16(&pCharInfo); CharInfo.BytesPerLine = GUI__Read16(&pCharInfo); GUI__Read16(&pCharInfo); /* Dummy */ CharInfo.OffData = GUI__Read32(&pCharInfo); pData = (const U8 *)GUI_Context.pAFont->p.pFontData + CharInfo.OffData; DrawMode = GUI_Context.TextMode; OldDrawMode = LCD_SetDrawMode(DrawMode); LCD_DrawBitmap(GUI_Context.DispPosX, GUI_Context.DispPosY, CharInfo.XSize, GUI_Context.pAFont->YSize, GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag, 1, CharInfo.BytesPerLine, pData, &LCD_BKCOLORINDEX); /* Fill empty pixel lines */ if (GUI_Context.pAFont->YDist > GUI_Context.pAFont->YSize) { int YMag = GUI_Context.pAFont->YMag; int YDist = GUI_Context.pAFont->YDist * YMag; int YSize = GUI_Context.pAFont->YSize * YMag; if (DrawMode != LCD_DRAWMODE_TRANS) { LCD_COLOR OldColor = GUI_GetColor(); GUI_SetColor(GUI_GetBkColor()); LCD_FillRect(GUI_Context.DispPosX, GUI_Context.DispPosY + YSize, GUI_Context.DispPosX + CharInfo.XSize, GUI_Context.DispPosY + YDist); GUI_SetColor(OldColor); } } LCD_SetDrawMode(OldDrawMode); /* Restore draw mode */ GUI_Context.DispPosX += CharInfo.XDist; } }
void DemoBitmap(void) { LCD_DrawBitmap(0,0,bmp_men); LCD_SetFont(1); LCD_PrintXY(6,0, "Bitmap"); }
void GUIMONO_DispChar(U16P c) { int c0, c1; U8 * pd; int x = GUI_Context.DispPosX; int y = GUI_Context.DispPosY; /* do some checking if drawing is actually necessary ... */ const GUI_FONT_MONO* pMono = GUI_Context.pAFont->p.pMono; unsigned int FirstChar = pMono->FirstChar; /* translate character into 2 characters to display : c0,c1 Check if regular character first. */ if ((c >= (U16P)FirstChar) &&(c <= (U16P)pMono->LastChar)) { pd = (U8*)pMono->pData; c0 = ((int)c) - FirstChar; c1 = -1; } else { /* Check if character is in translation table */ GUI_FONT_TRANSINFO const* pti = pMono->pTrans; pd = (U8*)pMono->pTransData; if (pti) { FirstChar = pti->FirstChar; if ((c >= (U16P)FirstChar) && (c <= (U16P)pti->LastChar)) { GUI_FONT_TRANSLIST const* ptl; c -= pti->FirstChar; ptl = pti->pList; ptl += c; c0 = ptl->c0; c1 = ptl->c1; } else { c0 = c1 = -1; } } else { c0 = c1 = -1; } } /* Draw first character if it is valid */ if (c0!=-1) { int BytesPerChar = GUI_Context.pAFont->YSize*pMono->BytesPerLine; GUI_DRAWMODE DrawMode; int XSize = pMono->XSize; int YSize = GUI_Context.pAFont->YSize; /* Select the right drawing mode */ DrawMode = GUI_Context.TextMode; /* call drawing routine */ { U8 OldMode = LCD_SetDrawMode(DrawMode); LCD_DrawBitmap( x, y, XSize, YSize, GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag, 1, /* Bits per Pixel */ pMono->BytesPerLine, pd + c0* BytesPerChar, &LCD_BKCOLORINDEX ); if (c1 != -1) { LCD_SetDrawMode(DrawMode | LCD_DRAWMODE_TRANS); LCD_DrawBitmap( x, y, XSize, YSize, GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag, 1, /* Bits per Pixel */ pMono->BytesPerLine, pd + c1* BytesPerChar, &LCD_BKCOLORINDEX ); } /* Fill empty pixel lines */ if (GUI_Context.pAFont->YDist > GUI_Context.pAFont->YSize) { int YMag = GUI_Context.pAFont->YMag; int YDist = GUI_Context.pAFont->YDist * YMag; int YSize = GUI_Context.pAFont->YSize * YMag; if (DrawMode != LCD_DRAWMODE_TRANS) { LCD_SetDrawMode(DrawMode ^ LCD_DRAWMODE_REV); /* Reverse so we can fill with BkColor */ LCD_FillRect(x, y + YSize, x + XSize, y + YDist); } } LCD_SetDrawMode(OldMode); } } GUI_Context.DispPosX+=pMono->XDist; }
/********************************************************************* * * _DrawBitmap */ static void _DrawBitmap(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag, tLCDDEV_Index2Color * pfIndex2Color) { const U32 * pData; int y, OldIndex, Mag, BytesPerLine, UseDrawBitmap = 0; U32 PrevColor; GUI_USE_PARA(pLogPal); OldIndex = LCD_GetColorIndex(); PrevColor = GUI_INVALID_COLOR; pData = (const U32 *)pPixel; Mag = (xMag | yMag); BytesPerLine = xsize * 4; /* Check if bitmaps color format fits to the current color conversion */ if (Mag == 1) { #if GUI_SUPPORT_MEMDEV if (!GUI_Context.hDevData) { #else { #endif if (LCD_GetpfIndex2ColorEx(GUI_Context.SelLayer) == pfIndex2Color) { UseDrawBitmap = 1; } } } if (UseDrawBitmap) { LCD_DrawBitmap(x0, y0, xsize, ysize, 1, 1, 24, BytesPerLine, pPixel, 0); } else { if (Mag == 1) { /* Perform clipping */ int x1, y1, Diff; y1 = y0 + ysize - 1; x1 = x0 + xsize - 1; /* Clip Y */ if (y0 < GUI_Context.ClipRect.y0) { Diff = GUI_Context.ClipRect.y0 - y0; y0 = GUI_Context.ClipRect.y0; #if GUI_SUPPORT_LARGE_BITMAPS /* Required only for 16 bit CPUs if some bitmaps are >64kByte */ pData += (U32)Diff * (U32)BytesPerLine / 4; #else pData += (unsigned)Diff * (unsigned)BytesPerLine / 4; #endif ysize -= Diff; } Diff = y1 - GUI_Context.ClipRect.y1; if (Diff > 0) { ysize -= Diff; } if (ysize <=0) { return; } /* Clip right side */ Diff = x1 - GUI_Context.ClipRect.x1; if (Diff > 0) { xsize -= Diff; } /* Clip left side */ if (x0 < GUI_Context.ClipRect.x0) { Diff = GUI_Context.ClipRect.x0 - x0; xsize -= Diff; pData += Diff; x0 += Diff; } if (xsize <=0) { return; } /* Simple, unmagnified output using LCD_L0_SetPixel() */ for (y = 0; y < ysize; y++) { int x; const U32 * p = pData; for (x = 0; x < xsize; x++) { U32 Color; Color = *p++; if (Color != PrevColor) { LCD_SetColor(pfIndex2Color(Color)); PrevColor = Color; } LCDDEV_L0_SetPixelIndex(x + x0, y + y0, LCD_COLORINDEX); } pData += BytesPerLine / 4; } } else { /* Magnified output using LCD_FillRect() */ int x,y; int yi; for (y = y0, yi = 0; yi < ysize; yi++, y += yMag, pPixel += BytesPerLine) { int yMax; yMax = y + yMag - 1; /* Draw if within clip area */ if ((yMax >= GUI_Context.ClipRect.y0) && (y <= GUI_Context.ClipRect.y1)) { int xi; const U32 GUI_UNI_PTR * p = pData; for (x = x0, xi = 0; xi < xsize; xi++, x += xMag) { U32 Color; Color = *p++; if (Color != PrevColor) { LCD_SetColor(pfIndex2Color(Color)); PrevColor = Color; } LCD_FillRect(x, y, x + xMag - 1, yMax); } } pData += BytesPerLine / 4; } } GUI_SetColorIndex(OldIndex); } } /********************************************************************* * * _DrawBitmap_565 */ static void _DrawBitmap_888(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag) { _DrawBitmap(x0, y0, xsize, ysize, pPixel, pLogPal, xMag, yMag, GUI_BitmapMethods888.pfIndex2Color); }