LCDPM233.c
上传用户:pch188
上传日期:2013-04-20
资源大小:6697k
文件大小:2k
源码类别:

微处理器开发

开发平台:

C/C++

  1. /* ********************************************************************************************************* *                                                uC/GUI *                        Universal graphic software for embedded applications * *                       (c) Copyright 2002, Micrium Inc., Weston, FL *                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH * *              礐/GUI is protected by international copyright laws. Knowledge of the *              source code may not be used to write a similar product. This file may *              only be used in accordance with a license and should not be redistributed *              in any way. We appreciate your understanding and fairness. * ----------------------------------------------------------------------
  2. File        : LCDPM233.C
  3. Purpose     : Color conversion routines for -233 mode
  4. ---------------------------END-OF-HEADER------------------------------
  5. */
  6. #include <stddef.h>           /* needed for definition of NULL */
  7. #include "LCD_Protected.h"    /* inter modul definitions */
  8. /*********************************************************************
  9. *
  10. *       LCD_FIXEDPALETTE == -233
  11. *
  12. *       256 colors     RRGGGBBB
  13. *
  14. **********************************************************************
  15. */
  16. int LCD_Color2Index_M233(LCD_COLOR Color) {
  17.   int r, g, b;
  18.   r = Color & 255;
  19.   g = (Color >> 8 ) & 255;
  20.   b = Color >> 16;
  21.   r = (r + 42 ) / 85;
  22.   g = (g * 7 + 127) / 255;
  23.   b = (b * 7 + 127) / 255;
  24.   return b + (g << 3) + (r << 6);
  25. }
  26. LCD_COLOR LCD_Index2Color_M233(int Index) {
  27.   int r, g, b;
  28.   b = (Index & 7) * 255 / 7;
  29.   g = ((Index >> 3) & 7) * 255 / 7;
  30.   r = ((Index >> 6) & 3) * 85;
  31.   return r + (g << 8) + (((U32)b) << 16);
  32. }