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

📄 r2d_customer_lcd_i.c

📁 是一个手机功能的模拟程序
💻 C
字号:
//6.13,chenjun &zym change
static UINT32 r2d_lcd_copy_operator(UINT32 old,UINT32 value)
{
	return(value);
}
static UINT32 r2d_lcd_or_operator(UINT32 old,UINT32 value)
{
	return(old | value) ;
}
static UINT32 r2d_lcd_and_operator(UINT32 old,UINT32 value)
{
	return(old & value);
}
static UINT32 r2d_lcd_xor_operator(UINT32 old,UINT32 value)
{
	return(old ^ value) ;
}
static UINT32 r2d_lcd_not_copy_operator(UINT32 old,UINT32 value)
{
	return(~value);
}
static UINT32 r2d_lcd_not_or_operator(UINT32 old,UINT32 value)
{
	return(~(old | value));
}
static UINT32 r2d_lcd_not_and_operator(UINT32 old,UINT32 value)
{
	return(~(old & value));
}
static UINT32 r2d_lcd_not_xor_operator(UINT32 old,UINT32 value)
{
	return(~(old ^ value)) ;
}

const T_R2D_DRAWING_OPERATORS r2d_g_lcd_operators=
{
   &r2d_lcd_copy_operator,
   &r2d_lcd_or_operator,
   &r2d_lcd_and_operator,
   &r2d_lcd_xor_operator,
   &r2d_lcd_not_copy_operator,
   &r2d_lcd_not_or_operator,
   &r2d_lcd_not_and_operator,
   &r2d_lcd_not_xor_operator,
   NULL
};

// Return the pixel value to write on the LCD or the offscreen
// pixmap
// LCD DEPENDENT
void r2d_convert_foreground_color(T_R2D_GC *gc,UINT32 color)
{
     
     // If one is writing to the LCD framebuffer (the only
     // one which is not 24 bits) then color conversion is required
        UINT16 red,green,blue;
        UINT32 lightness;

      
        red=r2d_red(color);
        green=r2d_green(color);
        blue=r2d_blue(color);

                 color = 0x0;

         //here changed by ZYM to corrrect color, chenjun add
        color = (red/8)<<11;
        color |=(green/4)<<5;
        color |=(blue/8);             
/*
        color = (red/16)<<8;
        color |=(green/16)<<4;
        color |=(blue/16);           //changed by zp at 3/8
*/
    
        
        // Compute global intensity for monochrome LCD
        lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF);       

  #if (R2D_DITHERING == R2D_ON)
        {
          UINT32 dvalue;
          UINT16 dithering_group;

          r2d_dithering_group_and_lightness();

          r2d_dithered_value(0,0)
          r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache,
            color,0,0);

          r2d_dithered_value(0,1)
          r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache,
            color,0,1);

          r2d_dithered_value(1,1)
          r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache,
            color,1,1);

          r2d_dithered_value(1,0)
          r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache,
            color,1,0);


        }
  #else
          lightness=(lightness >> (8 - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK;
          gc->foreground_pixel_value=lightness;
  #endif

     
     
}

// Return the pixel value to write on the LCD or the offscreen
// pixmap
// LCD DEPENDENT
void r2d_convert_background_color(T_R2D_GC *gc,UINT32 color)
{
     
     // If one is writing to the LCD framebuffer (the only
     // one which is not 24 bits) then color conversion is required
        UINT16 red,green,blue;
        UINT32 lightness;

      
        red=r2d_red(color);
        green=r2d_green(color);
        blue=r2d_blue(color);

         color = 0x0;

         //here changed by ZYM to corrrect color, chenjun add
        color = (red/8)<<11;
        color |=(green/4)<<5;
        color |=(blue/8);             
/*
        color = (red/16)<<8;
        color |=(green/16)<<4;
        color |=(blue/16);           //changed by zp at 3/8
*/
        // Compute global intensity for monochrome LCD
        lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF);       

  #if (R2D_DITHERING == R2D_ON)
        {
          UINT32 dvalue;
          UINT16 dithering_group;

          r2d_dithering_group_and_lightness();

          r2d_dithered_value(0,0)
          r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache,
            color,0,0);

          r2d_dithered_value(0,1)
          r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache,
            color,0,1);

          r2d_dithered_value(1,1)
          r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache,
            color,1,1);

          r2d_dithered_value(1,0)
          r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache,
            color,1,0);


        }
  #else
          lightness=(lightness >> (8 - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK;
          gc->background_pixel_value=lightness;
  #endif


     
     
     
}

// blit_rect may use the foreground and background color
// to do the copy. So, one must knows which source pixels
// are corresponding to the background color,
// which ones are corresponding to the foreground color
// and do the conversion of the color selected
// according to the destination framebuffer

// This files gives routines for:
//  - Selecting a color according to the value in the LCD framebuffer
//  - Converting a color to LCD


// Convert a LCD value (not color) to a value
// to be written into the 24bpp framebuffer
// In general, the value written is a packed
// representation of the ARGB color
// but it may be different according to the framebuffer
// internal format
BOOLEAN r2d_lcd_foreground_pixel(UINT32 lcd_value,T_R2D_GC_PTR src_gc)
{
   if (lcd_value)
    return(TRUE); // Foreground pixel
   else
    return(FALSE); // Background pixel
}

// Assume than color framebuffer contains ARGB packed values
// Convert color to LCD with on the fly dithering
UINT32 r2d_color_to_lcd(UINT32 pixel_value,INT16 x,INT16 y)
{

  INT16 red,green,blue;
  UINT32 lightness;
  UINT32 dvalue;
  UINT16 dithering_group;

  pixel_value=(~pixel_value) & 0x00FFFFFF;
  red=r2d_red(pixel_value);
  green=r2d_green(pixel_value);
  blue=r2d_blue(pixel_value);

  // Compute global intensity for monochrome LCD
  lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF);       
 

  r2d_dithering_group_and_lightness();

  r2d_dithered_value(x & 1,y & 1);
          
  return(dvalue);
}

// Lcd to pixel value
UINT32 r2d_lcd_to_color(UINT32 color)
{
  UINT32 red,green,blue;
  /*  
  if (color)
    return(0x00FFFFFF); // 24 bpp framebuffer pixel value for white
  else
	return(0x00000000);*/

  red=r2d_bytetored(color) ;
  green=r2d_bytetogreen(color);
  blue=r2d_bytetoblue(color);

  color = 0x0;
  color=red<<16;          
  color |=green<<8;
  color |=blue;
  color &=0x00FFFFFF;	

  return(color);//zy add lcd from 16 to 32     
}



⌨️ 快捷键说明

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