/********************************************************************* * * _WriteAlphaToActiveAt */ static void _WriteAlphaToActiveAt(GUI_MEMDEV_Handle hMem, int Intens, int x, int y) { /* Make sure the memory handle is valid */ if (hMem) { GUI_MEMDEV * pDev = GUI_MEMDEV_H2P(hMem); GUI_USAGE_h hUsage = pDev->hUsage; GUI_USAGE* pUsage; int YSize = pDev->YSize; int yi; if (hUsage) { pUsage = GUI_USAGE_H2P(hUsage); for (yi = 0; yi < YSize; yi++) { int xOff = 0; int XSize; XSize = GUI_USAGE_GetNextDirty(pUsage, &xOff, yi); /* Draw the partial line which needs to be drawn */ for (; XSize; ) { U8* pData; pData = (U8*)GUI_MEMDEV__XY2PTREx(pDev, xOff, yi); do { LCD_COLOR Color, BkColor; int xPos, yPos, Index; if (pDev->BitsPerPixel == 8) { Index = *pData++; } else { Index = *(U16*)pData; pData += 2; } Color = LCD_Index2Color(Index); xPos = xOff + x; yPos = yi +y; BkColor = LCD_GetPixelColor(xPos, yPos); Color = LCD_MixColors256(Color, BkColor, Intens); Index = LCD_Color2Index(Color); LCD_SetPixelIndex(xPos, yPos, Index); xOff++; } while (--XSize); XSize = GUI_USAGE_GetNextDirty(pUsage, &xOff, yi); } } } } }
/********************************************************************* * * _DrawBitmap_RLE8 */ static void _DrawBitmap_RLE8(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) { LCD_PIXELINDEX aColorIndex[2]; LCD_PIXELINDEX PixelIndex; int xi,y; int xL, yL; const U8 GUI_UNI_PTR * pPixelOrg = pPixel; char NoTrans = !(GUI_Context.DrawMode & LCD_DRAWMODE_TRANS); const LCD_PIXELINDEX* pTrans =NULL; char IsMagnified = ((yMag | xMag) != 1); aColorIndex[0] = LCD_ACOLORINDEX[0]; aColorIndex[1] = LCD_ACOLORINDEX[1]; /* Handle color translation */ if ((pLogPal) && (pLogPal->pPalEntries)) { if ((pTrans = LCD_GetpPalConvTable(pLogPal)) == NULL) { return; } } /* Check if we can limit the number of lines due to clipping) */ if (yMag == 1) { if (ysize > GUI_Context.ClipRect.y1 - y0 + 1) ysize = GUI_Context.ClipRect.y1 - y0 + 1; } /* Init variables for looping */ xi=0; y =0; /* Check if we can use the cache to save some unnecessary iterations */ if (!IsMagnified) { int yDiff = GUI_Context.ClipRect.y0 - y0; if ((Cache.pPixelStart == pPixel) && (yDiff > Cache.y)) { /* Accept cache values */ y = Cache.y; xi = Cache.x; pPixel = Cache.pPixel; } } /* Init values for caching */ Cache.pPixel = Cache.pPixelStart = pPixelOrg; Cache.x = Cache.y = 0; /* Repeat until we have reached bottom */ for (; y < ysize; ) { U8 Cmd = *pPixel++; U8 Data = *pPixel++; if (Cmd) { /* Save cache info */ Cache.pPixel = pPixel-2; Cache.x = xi; Cache.y = y; LCD_ACOLORINDEX[1] = pTrans ? *(pTrans+Data) : Data; while (Cmd) { int xi1 = xi+Cmd; if (xi1>=xsize) xi1 = xsize; Cmd -= (xi1-xi); if (Data || NoTrans) { /* Skip transparent pixels */ if (IsMagnified) { xL = xMag * xi + x0; yL = yMag * y + y0; LCD_FillRect(xL, yL, xL + xMag * (xi1 - xi) -1 , yL + yMag - 1); } else { LCD_DrawHLine(x0+xi, y + y0, xi1+x0-1); } } xi =xi1; if (xi1==xsize) { y++; xi=0; } } } else { do { U8 Index = *pPixel++; if (Index || NoTrans) { /* Skip transparent pixels */ int x = x0+xi; PixelIndex = pTrans ? *(pTrans+Index) : Index; if (IsMagnified) { LCD_SetColorIndex(PixelIndex); xL = xMag * xi + x0; yL = yMag * y + y0; LCD_FillRect(xL, yL, xL + xMag -1 , yL + yMag - 1); } else { #if 1 /* High speed variant */ if (y + y0>= GUI_Context.ClipRect.y0) if (x >= GUI_Context.ClipRect.x0) if (x <= GUI_Context.ClipRect.x1) LCDDEV_L0_SetPixelIndex(x, y + y0, PixelIndex); #else LCD_SetPixelIndex(x, y + y0, PixelIndex); #endif } } if (++xi >= xsize) { xi=0; y++; if (y >= ysize) break; } } while (--Data); } } LCD_ACOLORINDEX[0] = aColorIndex[0]; LCD_ACOLORINDEX[1] = aColorIndex[1]; }