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

📄 lcd6642x.c

📁 lpc2478+ucosII+ucgui源码
💻 C
📖 第 1 页 / 共 4 页
字号:
        Buffer &= ~BufferMask;
        Data = Index << (6 - (((i + x0) & 3) << 1));
        Buffer |= Data;
      }
      break;
    }
    if (BufferMask == 3) {
      BufferMask = 0xC0;
      BufferValid = 0;
      WRITE_VMEM0(Buffer);
    } else {
      BufferMask >>= 2;
    }
  }
  if (BufferValid) {
    WRITE_VMEM0(Buffer);
  }
}

#else

/*
        *********************************************************
        *
        *  Draw Bitmap 1 BPP no optimization
        *
        *********************************************************
*/

static void  DrawBitLine1BPP(int x, int y, U8 const *p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
  PIXELCOLOR pixels;
  PIXELCOLOR Index0 = *(pTrans+0);
  PIXELCOLOR Index1 = *(pTrans+1);
/*
// Jump to right entry point
*/
  pixels = *p;
  switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR)) {
  case 0:
    #if defined (SETNEXTPIXEL)
      SetPosXY(x,y);
    #endif
    switch (Diff&7) {
    case 0:
      goto WriteBit0;
    case 1:
      goto WriteBit1;
    case 2:
      goto WriteBit2;
    case 3:
      goto WriteBit3;
    case 4:
      goto WriteBit4;
    case 5:
      goto WriteBit5;
    case 6:
      goto WriteBit6;
    case 7:
      goto WriteBit7;
    }
    break;
  case LCD_DRAWMODE_TRANS:
    switch (Diff&7) {
    case 0:
      goto WriteTBit0;
    case 1:
      goto WriteTBit1;
    case 2:
      goto WriteTBit2;
    case 3:
      goto WriteTBit3;
    case 4:
      goto WriteTBit4;
    case 5:
      goto WriteTBit5;
    case 6:
      goto WriteTBit6;
    case 7:
      goto WriteTBit7;
    }
    break;
  case LCD_DRAWMODE_XOR:
    switch (Diff&7) {
    case 0:
      goto WriteXBit0;
    case 1:
      goto WriteXBit1;
    case 2:
      goto WriteXBit2;
    case 3:
      goto WriteXBit3;
    case 4:
      goto WriteXBit4;
    case 5:
      goto WriteXBit5;
    case 6:
      goto WriteXBit6;
    case 7:
      goto WriteXBit7;
    }
  }
/*
        Write with transparency
*/
  WriteTBit0:
    if (pixels&(1<<7)) SETPIXEL(x+0, y, Index1);
    if (!--xsize)
      return;
  WriteTBit1:
    if (pixels&(1<<6)) SETPIXEL(x+1, y, Index1);
    if (!--xsize)
      return;
  WriteTBit2:
    if (pixels&(1<<5)) SETPIXEL(x+2, y, Index1);
    if (!--xsize)
      return;
  WriteTBit3:
    if (pixels&(1<<4)) SETPIXEL(x+3, y, Index1);
    if (!--xsize)
      return;
  WriteTBit4:
    if (pixels&(1<<3)) SETPIXEL(x+4, y, Index1);
    if (!--xsize)
      return;
  WriteTBit5:
    if (pixels&(1<<2)) SETPIXEL(x+5, y, Index1);
    if (!--xsize)
      return;
  WriteTBit6:
    if (pixels&(1<<1)) SETPIXEL(x+6, y, Index1);
    if (!--xsize)
      return;
  WriteTBit7:
    if (pixels&(1<<0)) SETPIXEL(x+7, y, Index1);
    if (!--xsize)
      return;
    x+=8;
    pixels = *(++p);
    goto WriteTBit0;
/*
        Write without transparency
*/
#if defined (SETNEXTPIXEL)   /* Optimization ! */
  WriteBit0:
    SetNextPixel(x+0, y, (pixels&(1<<7)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit1:
    SetNextPixel(x+1, y, (pixels&(1<<6)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit2:
    SetNextPixel(x+2, y, (pixels&(1<<5)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit3:
    SetNextPixel(x+3, y, (pixels&(1<<4)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit4:
    SetNextPixel(x+4, y, (pixels&(1<<3)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit5:
    SetNextPixel(x+5, y, (pixels&(1<<2)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit6:
    SetNextPixel(x+6, y, (pixels&(1<<1)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit7:
    SetNextPixel(x+7, y, (pixels&(1<<0)) ? Index1 : Index0);
    if (!--xsize)
      return;
    x+=8;
    pixels = *(++p);
    goto WriteBit0;
#else
  WriteBit0:
    SETPIXEL(x+0, y, (pixels&(1<<7)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit1:
    SETPIXEL(x+1, y, (pixels&(1<<6)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit2:
    SETPIXEL(x+2, y, (pixels&(1<<5)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit3:
    SETPIXEL(x+3, y, (pixels&(1<<4)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit4:
    SETPIXEL(x+4, y, (pixels&(1<<3)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit5:
    SETPIXEL(x+5, y, (pixels&(1<<2)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit6:
    SETPIXEL(x+6, y, (pixels&(1<<1)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit7:
    SETPIXEL(x+7, y, (pixels&(1<<0)) ? Index1 : Index0);
    if (!--xsize)
      return;
    x+=8;
    pixels = *(++p);
    goto WriteBit0;
#endif
/*
        Write XOR mode
*/
  WriteXBit0:
    if (pixels&(1<<7))
      XORPIXEL(x+0, y);
    if (!--xsize)
      return;
  WriteXBit1:
    if (pixels&(1<<6))
      XORPIXEL(x+1, y);
    if (!--xsize)
      return;
  WriteXBit2:
    if (pixels&(1<<5))
      XORPIXEL(x+2, y);
    if (!--xsize)
      return;
  WriteXBit3:
    if (pixels&(1<<4))
      XORPIXEL(x+3, y);
    if (!--xsize)
      return;
  WriteXBit4:
    if (pixels&(1<<3))
      XORPIXEL(x+4, y);
    if (!--xsize)
      return;
  WriteXBit5:
    if (pixels&(1<<2))
      XORPIXEL(x+5, y);
    if (!--xsize)
      return;
  WriteXBit6:
    if (pixels&(1<<1))
      XORPIXEL(x+6, y);
    if (!--xsize)
      return;
  WriteXBit7:
    if (pixels&(1<<0))
      XORPIXEL(x+7, y);
    if (!--xsize)
      return;
    x+=8;
    pixels = *(++p);
    goto WriteXBit0;
}

#endif

/*
        *********************************************************
        *
        *  Draw Bitmap 2 BPP, optimized
        *
        *********************************************************
*/

#if (LCD_MAX_LOG_COLORS > 2)

#if (LCD_OPTIMIZE)               \
    && (LCD_BITSPERPIXEL == 2)   \
    && (LCD_SWAP_XY ==1)         \
    && (LCD_MIRROR_X==1)         \
    && (LCD_MIRROR_Y==0)         \
    && (!defined (LCD_LUT_SEG))

static void DrawBitLine2BPP_Swap(
  int x,
  int y,
  U8 const * pData,
  int ysize,
  const U8 * pTrans,
  int BytesPerLine,
  U8 Pos)
{
  int i;
  int y0 = LCD_XSIZE - x - 1;
  int x0 = y;
  int x0Byte = y >> 2;
  U8 Buffer, DataMask, Index, Data, ShiftPos, BufferMask;
  U8 BufferValid = 0;
  SET_Y0(y0);
  SET_X0(x0Byte);
  ShiftPos = (Pos & 3) << 1;
  BufferMask = 0xC0 >> ((x0  & 3) << 1);
  DataMask =   0xC0 >> ShiftPos;
  for (i = 0; i < ysize; i++, pData += BytesPerLine) {
    if (!BufferValid) {
      READ_VMEM0(Buffer);
      BufferValid = 1;
    }
    switch (GUI_Context.DrawMode) {
    case LCD_DRAWMODE_NORMAL:
    case LCD_DRAWMODE_REV:
      Buffer &= ~BufferMask;
      Index = *(pTrans + ((*pData & DataMask) >> (6 - ShiftPos)));
      Data = Index << (6 - (((i + x0) & 3) << 1));
      Buffer |= Data;
      break;
    case LCD_DRAWMODE_XOR:
      Index = *(pTrans + ((*pData & DataMask) >> (6 - ShiftPos))) * 3;
      Data = Index << (6 - (((i + x0) & 3) << 1));
      Buffer ^= Data;
      break;
    case LCD_DRAWMODE_TRANS:
      Index = *(pTrans + ((*pData & DataMask) >> (6 - ShiftPos)));
      if (Index) {
        Buffer &= ~BufferMask;
        Data = Index << (6 - (((i + x0) & 3) << 1));
        Buffer |= Data;
      }
      break;
    }
    if (BufferMask == 3) {
      BufferMask = 0xC0;
      BufferValid = 0;
      WRITE_VMEM0(Buffer);
    } else {
      BufferMask >>= 2;
    }
  }
  if (BufferValid) {
    WRITE_VMEM0(Buffer);
  }
}

/*
        *********************************************************
        *
        *  Draw Bitmap 2 BPP no optimization
        *
        *********************************************************
*/

#else

static void  DrawBitLine2BPP(int x, int y, U8 const *p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
  PIXELCOLOR pixels;
/*
// Jump to right entry point
*/
  pixels = *p;
  switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR)) {
  case 0:
    switch (Diff&3) {
    case 0:
      goto WriteBit0;
    case 1:
      goto WriteBit1;
    case 2:
      goto WriteBit2;
    default:
      goto WriteBit3;
    }
  case LCD_DRAWMODE_TRANS:
    switch (Diff&3) {
    case 0:
      goto WriteTBit0;
    case 1:
      goto WriteTBit1;
    case 2:
      goto WriteTBit2;
    default:
      goto WriteTBit3;
    }
  case LCD_DRAWMODE_XOR:
    switch (Diff&3) {
    case 0:
      goto WriteXBit0;
    case 1:
      goto WriteXBit1;
    case 2:
      goto WriteXBit2;
    default:
      goto WriteXBit3;
    }
  case LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR:
    switch (Diff&3) {
    case 0:
      goto WriteTXBit0;
    case 1:
      goto WriteTXBit1;
    case 2:
      goto WriteTXBit2;
    default:
      goto WriteTXBit3;
    }
  }
/*
        Write without transparency
*/
WriteBit0:
  SETPIXEL(x+0, y, *(pTrans+(pixels>>6)));
  if (!--xsize)
    return;
WriteBit1:
  SETPIXEL(x+1, y, *(pTrans+(3&(pixels>>4))));
  if (!--xsize)
    return;
WriteBit2:
  SETPIXEL(x+2, y, *(pTrans+(3&(pixels>>2))));
  if (!--xsize)
    return;
WriteBit3:
  SETPIXEL(x+3, y, *(pTrans+(3&(pixels))));
  if (!--xsize)
    return;
  pixels = *(++p);
  x+=4;
  goto WriteBit0;
/*
        Write with transparency
*/
WriteTBit0:
  if (pixels&(3<<6))
    SETPIXEL(x+0, y, *(pTrans+(pixels>>6)));
  if (!--xsize)
    return;
WriteTBit1:

⌨️ 快捷键说明

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