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

📄 pix_map_base_routines.c

📁 在SOPC平台上
💻 C
📖 第 1 页 / 共 5 页
字号:
      dest_line_ptr += 1;
    }
    src_ptr += src_increment;
    dest_ptr += dest_increment;
  }
}
/* original 24 to 32
void copy_pix_map_24_to_32(
                    void *src_ptr,
                    long src_active_width,
                    long src_active_height,
                    long src_line_width,
                    void *dest_ptr,
                    long dest_line_width
                  )
{
  int src_row, src_col;
  int next_pixel_prefetched = 0;
  unsigned long next_long_pixel = 0;
  unsigned long in_temp_long_pixel_1 = 0, in_temp_long_pixel_2 = 0, in_temp_long_pixel_3 = 0;
  void *src_line_ptr, *dest_line_ptr;
  
  long src_increment, dest_increment;
  
  src_increment = src_line_width * _24BPP;
  dest_increment = dest_line_width * _32BPP;
  
  for( src_row = 0 ; src_row < src_active_height ; src_row++ )
  {
    next_pixel_prefetched = 0;
    src_line_ptr = src_ptr;
    dest_line_ptr = dest_ptr;
    for( src_col = 0 ; src_col < src_active_width ; src_col++ )
    {
      if((int)(src_line_ptr) & 0x03)   // long aligned?
      {
        next_long_pixel  = ((*(unsigned char *)(src_line_ptr)) << 0 )  & 0x000000ff;
        src_line_ptr += 1;
        next_long_pixel |= ((*(unsigned char *)(src_line_ptr)) << 8 )  & 0x0000ff00;
        src_line_ptr += 1;
        next_long_pixel |= ((*(unsigned char *)(src_line_ptr)) << 16 ) & 0x00ff0000;
        src_line_ptr += 1;
      }
      else                  // long aligned
      {
        switch (next_pixel_prefetched & 0x03)
        {
          case (0) :
            in_temp_long_pixel_1 = *(unsigned long *)(src_line_ptr);
            src_line_ptr += 4;
            in_temp_long_pixel_2 = *(unsigned long *)(src_line_ptr);
            src_line_ptr += 4;
            in_temp_long_pixel_3 = *(unsigned long *)(src_line_ptr);
            src_line_ptr += 4;
            next_long_pixel = in_temp_long_pixel_1 & 0x00ffffff;
            next_pixel_prefetched = 0x03;
            break;
          case (1) :
            next_long_pixel = (in_temp_long_pixel_3 >> 8) & 0x00ffffff;
            next_pixel_prefetched--;
            break;
          case (2) :
            next_long_pixel = ((in_temp_long_pixel_2 >> 16) & 0x0000ffff) | ((in_temp_long_pixel_3 << 16) & 0x00ff0000);
            next_pixel_prefetched--;
            break;
          case (3) :
            next_long_pixel = ((in_temp_long_pixel_1 >> 24) & 0x000000ff) | ((in_temp_long_pixel_2 << 8) & 0x00ffff00);
            next_pixel_prefetched--;
            break;
        }
      }
          
      *(unsigned long *)(dest_line_ptr) = next_long_pixel;
      dest_line_ptr += 4;
    }
    src_ptr += src_increment;
    dest_ptr += dest_increment;
  }
}
*/
void copy_pix_map_24_to_24(
                    void *src_ptr,
                    long src_active_width,
                    long src_active_height,
                    long src_line_width,
                    void *dest_ptr,
                    long dest_line_width
                  )
{
  int src_row, src_col;
  void *src_line_ptr, *dest_line_ptr;
  long src_increment, dest_increment;

  src_increment = src_line_width + src_line_width + src_line_width;
  dest_increment = dest_line_width + dest_line_width + dest_line_width;
  
  for( src_row = 0 ; src_row < src_active_height ; src_row++ )
  {
    src_line_ptr = src_ptr;
    dest_line_ptr = dest_ptr;
    for( src_col = 0 ; src_col < src_active_width ; src_col++ )
    {
      *(unsigned char *)(dest_line_ptr) = (*(unsigned char *)(src_line_ptr));
      src_line_ptr += 1;
      dest_line_ptr += 1;
      *(unsigned char *)(dest_line_ptr) = (*(unsigned char *)(src_line_ptr));
      src_line_ptr += 1;
      dest_line_ptr += 1;
      *(unsigned char *)(dest_line_ptr) = (*(unsigned char *)(src_line_ptr));
      src_line_ptr += 1;
      dest_line_ptr += 1;
    }
    src_ptr += src_increment;
    dest_ptr += dest_increment;
  }
}

/* original 24 to 24
void copy_pix_map_24_to_24(
                    void *src_ptr,
                    long src_active_width,
                    long src_active_height,
                    long src_line_width,
                    void *dest_ptr,
                    long dest_line_width
                  )
{
  int src_row, src_col;
  int next_pixel_prefetched = 0;
  int last_pixel_buffered = 0;
  unsigned long next_long_pixel = 0;
  unsigned long in_temp_long_pixel_1 = 0, in_temp_long_pixel_2 = 0, in_temp_long_pixel_3 = 0;
  unsigned long out_temp_long_pixel_1 = 0, out_temp_long_pixel_2 = 0, out_temp_long_pixel_3 = 0;
  void *src_line_ptr, *dest_line_ptr;
  
  long src_increment, dest_increment;
  
  src_increment = src_line_width * _24BPP;
  dest_increment = dest_line_width * _24BPP;
  
  for( src_row = 0 ; src_row < src_active_height ; src_row++ )
  {
    next_pixel_prefetched = 0;
    last_pixel_buffered = 0;
    src_line_ptr = src_ptr;
    dest_line_ptr = dest_ptr;
    for( src_col = 0 ; src_col < src_active_width ; src_col++ )
    {
      if((int)(src_line_ptr) & 0x03)   // long aligned?
      {
        next_long_pixel  = ((*(unsigned char *)(src_line_ptr)) << 0 )  & 0x000000ff;
        src_line_ptr += 1;
        next_long_pixel |= ((*(unsigned char *)(src_line_ptr)) << 8 )  & 0x0000ff00;
        src_line_ptr += 1;
        next_long_pixel |= ((*(unsigned char *)(src_line_ptr)) << 16 ) & 0x00ff0000;
        src_line_ptr += 1;
      }
      else                  // long aligned
      {
        switch (next_pixel_prefetched & 0x03)
        {
          case (0) :
            in_temp_long_pixel_1 = *(unsigned long *)(src_line_ptr);
            src_line_ptr += 4;
            in_temp_long_pixel_2 = *(unsigned long *)(src_line_ptr);
            src_line_ptr += 4;
            in_temp_long_pixel_3 = *(unsigned long *)(src_line_ptr);
            src_line_ptr += 4;
            next_long_pixel = in_temp_long_pixel_1 & 0x00ffffff;
            next_pixel_prefetched = 0x03;
            break;
          case (1) :
            next_long_pixel = (in_temp_long_pixel_3 >> 8) & 0x00ffffff;
            next_pixel_prefetched--;
            break;
          case (2) :
            next_long_pixel = ((in_temp_long_pixel_2 >> 16) & 0x0000ffff) | ((in_temp_long_pixel_3 << 16) & 0x00ff0000);
            next_pixel_prefetched--;
            break;
          case (3) :
            next_long_pixel = ((in_temp_long_pixel_1 >> 24) & 0x000000ff) | ((in_temp_long_pixel_2 << 8) & 0x00ffff00);
            next_pixel_prefetched--;
            break;
        }
      }
          
      if((int)(dest_line_ptr) & 0x03)   // long aligned?
      {
        *(unsigned char *)(dest_line_ptr) = ( next_long_pixel >> 0 )  & 0x000000ff;
        dest_line_ptr += 1;
        *(unsigned char *)(dest_line_ptr) = ( next_long_pixel >> 8 )  & 0x000000ff;
        dest_line_ptr += 1;
        *(unsigned char *)(dest_line_ptr) = ( next_long_pixel >> 16 )  & 0x000000ff;
        dest_line_ptr += 1;
      }
      else                  // long aligned
      {
        switch (last_pixel_buffered & 0x03)
        {
          case (0) :
            out_temp_long_pixel_1 = next_long_pixel;
            last_pixel_buffered++;
            break;
          case (1) :
            out_temp_long_pixel_1 = (out_temp_long_pixel_1 & 0x00ffffff) | ((next_long_pixel << 24) & 0xff000000);
            out_temp_long_pixel_2 = ((next_long_pixel >> 8) & 0x0000ffff);
            last_pixel_buffered++;
            break;
          case (2) :
            out_temp_long_pixel_2 = (out_temp_long_pixel_2 & 0x0000ffff) | ((next_long_pixel << 16) & 0xffff0000);
            out_temp_long_pixel_3 = ((next_long_pixel >> 16) & 0x000000ff);
            last_pixel_buffered++;
            break;
          case (3) :
            *(unsigned long *)(dest_line_ptr) = out_temp_long_pixel_1;
            dest_line_ptr += 4;
            *(unsigned long *)(dest_line_ptr) = out_temp_long_pixel_2;
            dest_line_ptr += 4;
            *(unsigned long *)(dest_line_ptr) =  ((next_long_pixel << 8) & 0xffffff00) | (out_temp_long_pixel_3 & 0x000000ff);
            dest_line_ptr += 4;
            last_pixel_buffered = 0x00;
            break;
        }
      }
    }
    if(last_pixel_buffered)
    {
      switch (last_pixel_buffered & 0x03)
      {
        case (1) :
          *(unsigned char *)(dest_line_ptr) = ( out_temp_long_pixel_1 >> 0 )  & 0x000000ff;
          dest_line_ptr += 1;
          *(unsigned char *)(dest_line_ptr) = ( out_temp_long_pixel_1 >> 8 )  & 0x000000ff;
          dest_line_ptr += 1;
          *(unsigned char *)(dest_line_ptr) = ( out_temp_long_pixel_1 >> 16 )  & 0x000000ff;
          dest_line_ptr += 1;
          break;
        case (2) :
          *(unsigned long *)(dest_line_ptr) = out_temp_long_pixel_1;
          dest_line_ptr += 4;
          *(unsigned char *)(dest_line_ptr) = ( out_temp_long_pixel_2 >> 0 )  & 0x000000ff;
          dest_line_ptr += 1;
          *(unsigned char *)(dest_line_ptr) = ( out_temp_long_pixel_2 >> 8 )  & 0x000000ff;
          dest_line_ptr += 1;
          break;
        case (3) :
          *(unsigned long *)(dest_line_ptr) = out_temp_long_pixel_1;
          dest_line_ptr += 4;
          *(unsigned long *)(dest_line_ptr) = out_temp_long_pixel_2;
          dest_line_ptr += 4;
          *(unsigned char *)(dest_line_ptr) = ( out_temp_long_pixel_3 >> 0 )  & 0x000000ff;
          dest_line_ptr += 1;
          break;
      }
    }
    src_ptr += src_increment;
    dest_ptr += dest_increment;
  }
}

*/
void copy_pix_map_24_to_16(
                    void *src_ptr,
                    long src_active_width,
                    long src_active_height,
                    long src_line_width,
                    void *dest_ptr,
                    long dest_line_width
                  )
{
  int src_row, src_col;
  unsigned short next_short_pixel;
  void *src_line_ptr, *dest_line_ptr;
  long src_increment, dest_increment;

  src_increment = src_line_width + src_line_width + src_line_width;
  dest_increment = dest_line_width + dest_line_width;
  
  for( src_row = 0 ; src_row < src_active_height ; src_row++ )
  {
    src_line_ptr = src_ptr;
    dest_line_ptr = dest_ptr;
    for( src_col = 0 ; src_col < src_active_width ; src_col++ )
    {
      next_short_pixel  = ((*(unsigned char *)(src_line_ptr)) & 0xf8) << 8 ;
      src_line_ptr += 1;
      next_short_pixel |= ((*(unsigned char *)(src_line_ptr)) & 0xfc) << 3;
      src_line_ptr += 1;
      next_short_pixel |= ((*(unsigned char *)(src_line_ptr)) & 0xf8) >> 3;
      src_line_ptr += 1;
  
      *(unsigned short *)(dest_line_ptr) = next_short_pixel;
      dest_line_ptr += 2;
    }
    src_ptr += src_increment;
    dest_ptr += dest_increment;
  }
}
/* original 24 to 16
void copy_pix_map_24_to_16(
                    void *src_ptr,
                    long src_active_width,
                    long src_active_height,
                    long src_line_width,
                    void *dest_ptr,
                    long dest_line_width
                  )
{
  int src_row, src_col;
  int next_pixel_prefetched = 0;
  int last_pixel_buffered = 0;
  unsigned long next_long_pixel = 0;
  unsigned short next_short_pixel = 0;
  unsigned short last_short_pixel = 0;
  unsigned long in_temp_long_pixel_1 = 0, in_temp_long_pixel_2 = 0, in_temp_long_pixel_3 = 0;
  void *src_line_ptr, *dest_line_ptr;
  
  long src_increment, dest_increment;
  
  src_increment = src_line_width * _24BPP;
  dest_increment = dest_line_width * _16BPP;
  
  for( src_row = 0 ; src_row < src_active_height ; src_row++ )
  {
    next_pixel_prefetched = 0;
    last_pixel_buffered = 0;
    src_line_ptr = src_ptr;
    dest_line_ptr = dest_ptr;
    for( src_col = 0 ; src_col < src_active_width ; src_col++ )
    {
      if((int)(src_line_ptr) & 0x03)   // long aligned?
      {
        next_long_pixel  = ((*(unsigned char *)(src_line_ptr)) << 0 )  & 0x000000ff;
        src_line_ptr += 1;
        next_long_pixel |= ((*(unsigned char *)(src_line_ptr)) << 8 )  & 0x0000ff00;
        src_line_ptr += 1;
        next_long_pixel |= ((*(unsigned char *)(src_line_ptr)) << 16 ) & 0x00ff0000;
        src_line_ptr += 1;
      }
      else                  // long aligned
      {
        switch (next_pixel_prefetched & 0x03)
        {
          case (0) :
            in_temp_long_pixel_1 = *(unsigned long *)(src_line_ptr);
            src_line_ptr += 4;
            in_temp_long_pixel_2 = *(unsigned long *)(src_line_ptr);
            src_line_ptr += 4;
            in_temp_long_pixel_3 = *(unsigned long *)(src_line_ptr);
            src_line_ptr += 4;
            next_long_pixel = in_temp_long_pixel_1 & 0x00ffffff;
            next_pixel_prefetched = 0x03;
            break;
          case (1) :
            next_long_pixel = (in_temp_long_pixel_3 >> 8) & 0x00ffffff;
            next_pixel_prefetched--;
            break;
          case (2) :
            next_long_pixel = ((in_temp_long_pixel_2 >> 16) & 0x0000ffff) | ((in_temp_long_pixel_3 << 16) & 0x00ff0000);
            next_pixel_prefetched--;
            break;
          case (3) :
            next_long_pixel = ((in_temp_long_pixel_1 >> 24) & 0x000000ff) | ((in_temp_long_pixel_2 << 8) & 0x00ffff00);
            next_pixel_prefetched--;
            break;
        }
      }

⌨️ 快捷键说明

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