📄 pix_map_base_routines.c
字号:
{
if(next_pixel_prefetched)
{
next_short_pixel = ( next_prefetch_pixel >> 16 ) & 0x0000ffff;
next_pixel_prefetched--;
}
else
{
next_prefetch_pixel = *(unsigned long *)(src_line_ptr);
src_line_ptr += 4;
next_short_pixel = next_prefetch_pixel & 0x0000ffff;
next_pixel_prefetched = 0x01;
}
}
if((int)(dest_line_ptr) & 0x02) // short aligned?
{
*(unsigned short *)(dest_line_ptr) = next_short_pixel;
dest_line_ptr += 2;
}
else // long aligned
{
if(last_pixel_buffered)
{
*(unsigned long *)(dest_line_ptr) = ((next_short_pixel << 16) & 0xffff0000) | (last_short_pixel & 0x0000ffff);
dest_line_ptr += 4;
last_pixel_buffered = 0;
}
else
{
last_short_pixel = next_short_pixel;
last_pixel_buffered++;
}
}
}
if(last_pixel_buffered)
{
*(unsigned short *)(dest_line_ptr) = last_short_pixel;
dest_line_ptr += 2;
}
src_ptr += src_increment;
dest_ptr += dest_increment;
}
}
*/
void copy_pix_map_8_to_8(
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;
dest_increment = 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;
}
src_ptr += src_increment;
dest_ptr += dest_increment;
}
}
/* original working version */
/*
void copy_pix_map(
void *src_ptr,
long src_pixel_size,
long src_active_width,
long src_active_height,
long src_line_width,
void *dest_ptr,
long dest_pixel_size,
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 next_prefetch_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;
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;
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++ )
{
switch ( src_pixel_size )
{
case ( _16BPP ) :
if((int)(src_line_ptr) & 0x02) // short aligned?
{
next_short_pixel = *(unsigned short *)(src_line_ptr);
src_line_ptr += 2;
}
else // long aligned
{
if(next_pixel_prefetched)
{
next_short_pixel = ( next_prefetch_pixel >> 16 ) & 0x0000ffff;
next_pixel_prefetched--;
}
else
{
next_prefetch_pixel = *(unsigned long *)(src_line_ptr);
src_line_ptr += 4;
next_short_pixel = next_prefetch_pixel & 0x0000ffff;
next_pixel_prefetched = 0x01;
}
}
break;
case ( _24BPP ) :
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;
}
}
break;
case ( _32BPP ) :
next_long_pixel = *(unsigned long *)(src_line_ptr);
src_line_ptr += 4;
break;
}
switch ( dest_pixel_size )
{
case ( _16BPP ) :
if(src_pixel_size != _16BPP)
next_short_pixel = (((next_long_pixel >> 3) & 0x1f) << 11) |
(((next_long_pixel >> 10) & 0x3f) << 5) |
(((next_long_pixel >> 19) & 0x1f) << 0) ;
if((int)(dest_line_ptr) & 0x02) // short aligned?
{
*(unsigned short *)(dest_line_ptr) = next_short_pixel;
dest_line_ptr += 2;
}
else // long aligned
{
if(last_pixel_buffered)
{
*(unsigned long *)(dest_line_ptr) = ((next_short_pixel << 16) & 0xffff0000) | (last_short_pixel & 0x0000ffff);
dest_line_ptr += 4;
last_pixel_buffered = 0;
}
else
{
last_short_pixel = next_short_pixel;
last_pixel_buffered++;
}
}
break;
case ( _24BPP ) :
if(src_pixel_size == _16BPP)
next_long_pixel = (((next_short_pixel >> 0) & 0x1f) << 19) |
(((next_short_pixel >> 5) & 0x3f) << 10) |
(((next_short_pixel >> 11) & 0x1f) << 3) ;
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;
}
}
break;
case ( _32BPP ) :
if(src_pixel_size == _16BPP)
next_long_pixel = (((next_short_pixel >> 0) & 0x1f) << 19) |
(((next_short_pixel >> 5) & 0x3f) << 10) |
(((next_short_pixel >> 11) & 0x1f) << 3) ;
*(unsigned long *)(dest_line_ptr) = next_long_pixel;
dest_line_ptr += 4;
break;
}
}
if(last_pixel_buffered)
{
if((dest_pixel_size) == _16BPP)
{
*(unsigned short *)(dest_line_ptr) = last_short_pixel;
dest_line_ptr += 2;
}
else
{
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;
}
}
last_pixel_buffered = 0x00;
}
src_ptr += src_line_width * src_pixel_size;
dest_ptr += dest_line_width * dest_pixel_size;
}
}
*/
void blend_8_with_16_to_16(
void *alpha_ptr,
long alpha_active_width,
long alpha_active_height,
long alpha_color,
long alpha_line_width,
void *src_ptr,
long src_line_width,
void *dest_ptr,
long dest_line_width
)
{
int row, col;
void *alpha_line_ptr, *src_line_ptr, *dest_line_ptr;
long alpha_increment, src_increment, dest_increment;
unsigned char alpha_red, alpha_green, alpha_blue;
unsigned char src_red, src_green, src_blue;
unsigned char dest_red, dest_green, dest_blue;
unsigned char next_alpha;
unsigned short src_pixel;
alpha_red = (alpha_color >> 0) & 0x000000ff;
alpha_green = (alpha_color >> 8) & 0x000000ff;
alpha_blue = (alpha_color >> 16) & 0x000000ff;
alpha_increment = alpha_line_width;
src_increment = src_line_width + src_line_width;
dest_increment = dest_line_width + dest_line_width;
for( row = 0 ; row < alpha_active_height ; row++ )
{
alpha_line_ptr = alpha_ptr;
src_line_ptr = src_ptr;
dest_line_ptr = dest_ptr;
for( col = 0 ; col < alpha_active_width ; col++ )
{
src_pixel = *(unsigned short *)(src_line_ptr);
next_alpha = (*(unsigned char *)(alpha_line_ptr));
if(next_alpha)
{
src_red = ( ( src_pixel >> 11 ) & 0x1f ) << 3;
src_green = ( ( src_pixel >> 5 ) & 0x3f ) << 2;
src_blue = ( ( src_pixel >> 0 ) & 0x1f ) << 3;
dest_red = ( ( next_alpha * ( alpha_red - src_red ) ) >> 8 ) + src_red;
dest_green = ( ( next_alpha * ( alpha_green - src_green ) ) >> 8 ) + src_green;
dest_blue = ( ( next_alpha * ( alpha_blue - src_blue ) ) >> 8 ) + src_blue;
*(unsigned short *)(dest_line_ptr) = ((( dest_red >> 3 ) & 0x1f ) << 11 ) |
((( dest_green >> 2 ) & 0x3f ) << 5 ) |
((( dest_blue >> 3 ) & 0x1f ) << 0 );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -