|
发表于 2011-6-28 09:31:08
|
显示全部楼层
void gdi_image_Rotate_Slope(double x,double y ,double dx ,double dy ,U16 IMAGE_ID,double cosn,double sinn)
{
S32 i,
j,
n,
imge_width,
imge_width2,
imge_height,
imge_height2,
transit_layer_buff_size1,
transit_layer_buff_size2;
U16* transit_layer_buff_ptr1,
* transit_layer_buff_ptr2;
U16 a,r,g,b;
gdi_handle transit_layer1,transit_layer2,last_active_layer;
S32 j2,i2;
double wb,x0,y0,x1,y1,u,v;
gdi_layer_multi_layer_enable();
gdi_image_get_dimension_id(IMAGE_ID,&imge_width,&imge_height);
transit_layer_buff_size1=((imge_width)*(imge_height)*16)>>3;
transit_layer_buff_ptr1=(U16*)mmi_frm_scrmem_alloc(transit_layer_buff_size1);
gdi_layer_create_using_outside_memory(0,0,imge_width,imge_height,&transit_layer1,(PU8)transit_layer_buff_ptr1,transit_layer_buff_size1);
gdi_layer_push_and_set_active(transit_layer1);
gdi_layer_clear(GDI_COLOR_BLUE);
gdi_layer_set_source_key(TRUE, GDI_COLOR_BLUE);
gdi_image_draw_id(0,0,IMAGE_ID);
gdi_layer_pop_and_restore_active();
imge_width2=240;
imge_height2=320;
transit_layer_buff_size2=(imge_width2*imge_height2*16)>>3;
transit_layer_buff_ptr2=(U16*)mmi_frm_scrmem_alloc(transit_layer_buff_size2);
gdi_layer_create_using_outside_memory(0,0,imge_width2,imge_height2,&transit_layer2,(PU8)transit_layer_buff_ptr2,transit_layer_buff_size2);
gdi_layer_push_and_set_active(transit_layer2);
gdi_layer_clear(GDI_COLOR_BLUE);
gdi_layer_set_source_key(TRUE, GDI_COLOR_BLUE);
for(i=0;i<imge_height2;i++)
{
for(j=0;j<imge_width2;j++)
{
x0=((double)j-x)*cosn+((double)i-y)*sinn+dx;
y0=((double)i-y)*cosn-((double)j-x)*sinn+dy;
//x0=(j-x)*cosn+(i-y)*sinn;
//y0=imge_height+(i-y)*cosn-(j-x)*sinn;
j2=(S32)x0;
i2=(S32)y0;
if((i2<(imge_height-1))&&(j2<(imge_width-1))&&(i2>0)&&(j2>0))
{
v=y0-i2;
u=x0-j2;
if(u>0.5)
j2++;
if(v>0.5)
i2++;
*(transit_layer_buff_ptr2+(i)*imge_width2+j) = *(transit_layer_buff_ptr1+i2*imge_width+j2);
}
}
}
gdi_layer_pop_and_restore_active();
gdi_layer_get_active(&last_active_layer);
gdi_layer_flatten(last_active_layer,transit_layer2,NULL,NULL);
//gdi_layer_set_blt_layer(last_active_layer,transit_layer2,NULL,NULL);
gdi_layer_free(transit_layer1);
gdi_layer_free(transit_layer2);
mmi_frm_scrmem_free(transit_layer_buff_ptr1);
mmi_frm_scrmem_free(transit_layer_buff_ptr2);
gdi_layer_multi_layer_disable();
} |
|