Ejemplo n.º 1
0
/*********************************************************************
*
*       GUI_DrawBitmapEx
*/
void GUI_DrawBitmapEx(const GUI_BITMAP GUI_UNI_PTR * pBitmap, int x0, int y0,
                      int xCenter, int yCenter, int xMag, int yMag) {
  int OldIndex;
  #if (GUI_WINSUPPORT)
    GUI_RECT r;
  #endif
  GUI_LOCK();
  OldIndex = LCD_GetColorIndex();
  #if (GUI_WINSUPPORT)
    WM_ADDORG(x0, y0);
    if (xMag >= 0) {
      r.x0 = x0 + GUI__DivideRound32(((I32)(-xCenter) * (I32)(xMag)), 1000);
      r.x1 = x0 + GUI__DivideRound32(((I32)(pBitmap->XSize - xCenter - 1) * (I32)(xMag)), 1000);
    } else {
      r.x1 = x0 + GUI__DivideRound32(((I32)(-xCenter) * (I32)(xMag)), 1000);
      r.x0 = x0 + GUI__DivideRound32(((I32)(pBitmap->XSize - xCenter - 1) * (I32)(xMag)), 1000);
    }
    if (yMag >= 0) {
      r.y0 = y0 + GUI__DivideRound32(((I32)(-yCenter) * (I32)(yMag)), 1000);
      r.y1 = y0 + GUI__DivideRound32(((I32)(pBitmap->YSize - yCenter - 1) * (I32)(yMag)), 1000);
    } else {
      r.y1 = y0 + GUI__DivideRound32(((I32)(-yCenter) * (I32)(yMag)), 1000);
      r.y0 = y0 + GUI__DivideRound32(((I32)(pBitmap->YSize - yCenter - 1) * (I32)(yMag)), 1000);
    }
    WM_ITERATE_START(&r) {
  #endif
  GL_DrawBitmapEx(pBitmap, x0, y0, xCenter, yCenter, xMag, yMag);
  #if (GUI_WINSUPPORT)
    } WM_ITERATE_END();
  #endif
  LCD_SetColorIndex(OldIndex);
  GUI_UNLOCK();
}
Ejemplo n.º 2
0
/*********************************************************************
*
*       GL_DrawBitmapEx
*/
static void GL_DrawBitmapEx(const GUI_BITMAP GUI_UNI_PTR * pBitmap, int x0, int y0,
                            int xCenter, int yCenter, int xMag, int yMag) {
  LCD_PIXELINDEX Index, IndexPrev = 0;
  LCD_COLOR Color;
  int x, y, xi, yi, xSize, ySize, xAct, xStart, xMagAbs, xiMag, yMin, yMax, yEnd, yPrev, yStep;
  char Cached, HasTrans = 0;
  /* Use clipping rect to reduce calculation */
  yMin = GUI_Context.ClipRect.y0;
  yMax = GUI_Context.ClipRect.y1;
  /* Init some values */
  xSize    = pBitmap->XSize;
  ySize    = pBitmap->YSize;
  xMagAbs  = ((xMag < 0) ? -xMag : xMag);
  x0      -= (I32)((xMag < 0) ? xSize - xCenter - 1 : xCenter) * (I32)(xMagAbs) / (I32)(1000);
  yEnd     = y0 + GUI__DivideRound32(((I32)(-yCenter) * (I32)(yMag)), 1000);
  yPrev    = yEnd + 1;
  yStep = (yMag < 0) ? -1 : 1;
  if (pBitmap->pPal) {
    if (pBitmap->pPal->HasTrans) {
      HasTrans = 1;
    }
  }
  for (yi = 0; yi < ySize; yi++) {
    y = yEnd;
    yEnd = y0 + GUI__DivideRound32(((I32)(yi + 1 - yCenter) * (I32)(yMag)), 1000);
    if (y != yPrev) {
      yPrev = y;
      do {
        if ((y >= yMin) && (y <= yMax)) {
          xStart = -1;
          x      =  0;
          xiMag  =  0;
          Cached =  0;
          for (xi = 0; xi < xSize; xi++) {
            xiMag += xMagAbs;
            if (xiMag >= 1000) {
              xAct  = (xMag > 0) ? xi : xSize - xi - 1;
              Index = GUI_GetBitmapPixelIndex(pBitmap, xAct, yi);
              if (Index != IndexPrev || xStart == -1) {
                if ((Index == 0) && HasTrans) {
                  /* Transparent color ... clear cache */
                  if (Cached) {
                    LCD_DrawHLine(x0 + xStart, y, x0 + x - 1);
                    Cached = 0;
                  }
                } else {
                  /* Another color ... draw contents of cache */
                  if (Cached && xStart != -1) {
                    LCD_DrawHLine(x0 + xStart, y, x0 + x - 1);
                  }
                  xStart    = x;
                  Cached    = 1;
                  if (pBitmap->pMethods) {
                    Color = pBitmap->pMethods->pfIndex2Color(Index);
                  } else {
                    Color = pBitmap->pPal->pPalEntries[Index];
                  }
                  LCD_SetColorIndex(LCDDEV_L0_Color2Index(Color));
                }
                IndexPrev = Index;
              }
              do {
                x++;
                xiMag -= 1000;
              } while (xiMag >= 1000);
            }
          }
          /* Clear cache */
          if (Cached) {
            LCD_DrawHLine(x0 + xStart, y, x0 + x - 1);
          }
        }
        y += yStep;
      } while ((yMag < 0) ? (y > yEnd) : (y < yEnd));
    }
  }
}
Ejemplo n.º 3
0
/*********************************************************************
*
*       _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];
}
Ejemplo n.º 4
0
void GUI_SetColorIndex(int Index)   {
  GUI_LOCK(); {
    LCD_SetColorIndex(Index);
  } GUI_UNLOCK();
}