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

📄 gui_bmp.lst

📁 Keil C下通过的UCGUI,UCGUI的移植源代码
💻 LST
字号:
C51 COMPILER V8.05a   GUI_BMP                                                              04/11/2008 14:18:26 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE GUI_BMP
OBJECT MODULE PLACED IN GUI_BMP.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Core\GUI_BMP.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND P
                    -RINT(.\GUI_BMP.lst) OBJECT(GUI_BMP.obj)

line level    source

   1          /*
   2          *********************************************************************************************************
   3          *                                                uC/GUI
   4          *                        Universal graphic software for embedded applications
   5          *
   6          *                       (c) Copyright 2002, Micrium Inc., Weston, FL
   7          *                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
   8          *
   9          *              礐/GUI is protected by international copyright laws. Knowledge of the
  10          *              source code may not be used to write a similar product. This file may
  11          *              only be used in accordance with a license and should not be redistributed
  12          *              in any way. We appreciate your understanding and fairness.
  13          *
  14          ----------------------------------------------------------------------
  15          File        : GUI_BMP.c
  16          Purpose     : Implementation of GUI_BMP... functions
  17          ---------------------------END-OF-HEADER------------------------------
  18          */
  19          
  20          #include <math.h>
  21          
  22          #include "gui\Core\GUI_Private.h"
  23          
  24          /*********************************************************************
  25          *
  26          *       Static functions
  27          *
  28          **********************************************************************
  29          */
  30          
  31          static int _GetStep(int * pYSize, int * pY) {
  32   1        if (*pYSize > 0) {
  33   2          *pY = *pYSize - 1;
  34   2          return -1;
  35   2        } else if (*pYSize < 0) {
  36   2          *pYSize = -*pYSize;
  37   2          *pY = 0;
  38   2          return 1;
  39   2        } else {
  40   2          return 0;
  41   2        }
  42   1      }
  43          
  44          static int _DrawBitmap_Pal(const U8 * pData, int x0, int y0, int XSize, int YSize, int Bpp, int NumColors)
             - {
  45   1        int i, y, BytesPerLine, Step;
  46   1        Step = _GetStep(&YSize, &y);
  47   1        if (!Step) {
  48   2          return 1;
  49   2        }
  50   1        for (i = 0; i < NumColors; i++) {
  51   2          U8 r, g, b;
  52   2          b = *(pData);
  53   2          g = *(pData + 1);
C51 COMPILER V8.05a   GUI_BMP                                                              04/11/2008 14:18:26 PAGE 2   

  54   2          r = *(pData + 2);
  55   2          pData += 4;
  56   2          LCD__aConvTable[i] = LCD_Color2Index((b << 16) | (g << 8) | r);
  57   2        }
  58   1        switch (Bpp) {
  59   2          case 1:
  60   2            BytesPerLine = ((XSize + 31) >> 5) << 2;
  61   2            break;
  62   2          case 4:
  63   2            BytesPerLine = (((XSize << 2) + 31) >> 5) << 2;
  64   2            break;
  65   2          case 8:
  66   2            BytesPerLine = ((XSize +  3) >> 2) << 2;
  67   2            break;
  68   2        }
  69   1        for (; (y < YSize) && (y >= 0); y += Step) {
  70   2          LCD_DrawBitmap(x0, y0 + y, XSize, 1, 1, 1, Bpp, XSize, pData, LCD__aConvTable);
  71   2          pData += BytesPerLine;
  72   2        }
  73   1        return 0;
  74   1      }
  75          
  76          static int _DrawBitmap_24bpp(const U8 * pData, int x0, int y0, int XSize, int YSize) {
  77   1        int x, y, BytesPerLine, Step;
  78   1        Step = _GetStep(&YSize, &y);
  79   1        if (!Step) {
  80   2          return 1;
  81   2        }
  82   1        BytesPerLine = ((24 * XSize + 31) >> 5) << 2;
  83   1        for (; (y < YSize) && (y >= 0); y += Step) {
  84   2          for (x = 0; x < XSize; x++) {
  85   3            const U8 * pColor = pData + 3 * x;
  86   3            U8 r, g, b;
  87   3            b = *(pColor);
  88   3            g = *(pColor + 1);
  89   3            r = *(pColor + 2);
  90   3            LCD_SetPixelIndex(x0 + x, y0 + y, LCD_Color2Index((b << 16) | (g << 8) | r));
  91   3          }
  92   2          pData += BytesPerLine;
  93   2        }
  94   1        return 0;
  95   1      }
  96          
  97          static U16 _Read16(U8 ** ppData) {
  98   1        U8 * pData = *ppData;
  99   1        U16 Value = *pData;
 100   1        Value |= (U16)(*(pData + 1) << 8);
 101   1        pData += 2;
 102   1        *ppData = pData;
 103   1        return Value;
 104   1      }
 105          
 106          static U32 _Read32(U8 ** ppData) {
 107   1        U8 * pData = *ppData;
 108   1        U32 Value = *pData;
 109   1        Value |= (U32)(*(pData + 1) << 8);
 110   1        Value |= (U32)(*(pData + 2) << 16);
 111   1        Value |= (U32)(*(pData + 3) << 24);
 112   1        pData += 4;
 113   1        *ppData = pData;
 114   1        return Value;
 115   1      }
C51 COMPILER V8.05a   GUI_BMP                                                              04/11/2008 14:18:26 PAGE 3   

 116          
 117          /*********************************************************************
 118          *
 119          *       GUI_BMP_GetXSize
 120          *
 121          **********************************************************************
 122          */
 123          int GUI_BMP_GetXSize(const void * pBMP) {
 124   1        U8 * pSrc = (U8 *)pBMP;
 125   1        if (!pBMP) {
 126   2          return 0;
 127   2        }
 128   1        pSrc += 18;                   /* skip rest of BITMAPFILEHEADER */
 129   1        return _Read32(&pSrc);
 130   1      }
 131          
 132          /*********************************************************************
 133          *
 134          *       GUI_BMP_GetXSize
 135          *
 136          **********************************************************************
 137          */
 138          int GUI_BMP_GetYSize(const void * pBMP) {
 139   1        U8 * pSrc = (U8 *)pBMP;
 140   1        if (!pBMP) {
 141   2          return 0;
 142   2        }
 143   1        pSrc += 22;
 144   1        return abs(_Read32(&pSrc));
 145   1      }
 146          
 147          /*********************************************************************
 148          *
 149          *       GUI_BMP_Draw
 150          *
 151          **********************************************************************
 152          */
 153          
 154          int GUI_BMP_Draw(const void * pBMP, int x0, int y0) {
 155   1        #if (GUI_WINSUPPORT)
                  GUI_RECT r;
                #endif
 158   1        int Ret;
 159   1        I32 Width, Height;
 160   1        U16 BitCount, Type;
 161   1        U32 ClrUsed, Compression;
 162   1        int NumColors;
 163   1        U8 * pSrc = (U8 *)pBMP;
 164   1        Type        = _Read16(&pSrc); /* get type from BITMAPFILEHEADER */
 165   1        pSrc += 12;                   /* skip rest of BITMAPFILEHEADER */
 166   1        /* get values from BITMAPINFOHEADER */
 167   1        pSrc += 4;
 168   1        Width       = _Read32(&pSrc);
 169   1        Height      = _Read32(&pSrc);
 170   1        pSrc += 2;
 171   1        BitCount    = _Read16(&pSrc);
 172   1        Compression = _Read32(&pSrc);
 173   1        pSrc += 12;
 174   1        ClrUsed     = _Read32(&pSrc);
 175   1        pSrc += 4;
 176   1        /* calculate number of colors */
 177   1        switch (BitCount) {
C51 COMPILER V8.05a   GUI_BMP                                                              04/11/2008 14:18:26 PAGE 4   

 178   2          case 0:   return 1; /* biBitCount = 0 (JPEG format) not supported. Please convert image ! */
 179   2          case 1:   NumColors = 2;   break;
 180   2          case 4:   NumColors = 16;  break;
 181   2          case 8:   NumColors = 256; break;
 182   2          case 24:  NumColors = 0;   break;
 183   2          default:
 184   2            return 1; /* biBitCount should be 1, 4, 8 or 24 */
 185   2        }
 186   1        if (NumColors && ClrUsed) {
 187   2          NumColors = ClrUsed;
 188   2        }
 189   1        /* check validity of bmp */
 190   1        if ((NumColors > LCD_MAX_LOG_COLORS) ||
 191   1            (Type != 0x4d42)                 || /* 'BM' */
 192   1            (Compression)                    || /* only uncompressed bitmaps */
 193   1            (Width  > 1024)                  ||
 194   1            (Height > 1024)) {
 195   2          return 1;
 196   2        }
 197   1        /* start output */
 198   1        GUI_LOCK();
 199   1        #if (GUI_WINSUPPORT)
                  WM_ADDORG(x0,y0);
                  r.x1 = (r.x0 = x0) + Width - 1;
                  r.y1 = (r.y0 = y0) + Height - 1;
                  WM_ITERATE_START(&r) {
                #endif
 205   1        /* Show bitmap */
 206   1        switch (BitCount) {
 207   2          case 1:
 208   2          case 4:
 209   2          case 8:
 210   2            Ret = _DrawBitmap_Pal(pSrc, x0, y0, Width, Height, BitCount, NumColors);
 211   2            break;
 212   2          case 24:
 213   2            Ret = _DrawBitmap_24bpp(pSrc, x0, y0, Width, Height);
 214   2            break;
 215   2        }
 216   1        #if (GUI_WINSUPPORT)
                  } WM_ITERATE_END();
                #endif
 219   1        GUI_UNLOCK();
 220   1        return Ret;
 221   1      }
 222          
 223          
 224          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2202    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----     118
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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