예제 #1
0
void long_shadow(){ // WE LOVE IT! NO ANTIALIAS!!
	s16 x, y;
	LCD_SetWindow(30, 30, 210, 210);
	for (y=30;y<240;y++)for (x=30;x<240;x++){
		if (((x-120)*(x-120)+(y-120)*(y-120)<119*119)&&
			(x>y-138)&&(x<y+138)&&(x+y>240))
				LCD_MixPixel_x32(0x0, 12);
		else
			LCD_GetPixel();
	}

}
예제 #2
0
/*
*********************************************************************************************************
*	函 数 名: GUI_Copy_ScreenRect()
*	功能说明: 屏幕截图,然后以bmp图片格式(为24位高真彩位图)保存到指定的路径下
*	形    参:x:X坐标   y:y坐标   sizex:长度   sizey:宽度
*             *Save_Path:保存路径,其中文件名后缀必须为bmp
*             例如:"0:/Picture/abcd.bmp" 注意!!:路径"0:/0:/Picture"必须存在
*             否则该函数调用无效。            	
*	返 回 值: 无
*********************************************************************************************************
*/
void GUI_SaveBMP(uint16_t startx,uint16_t starty,uint16_t sizex,uint16_t sizey,void *Save_Path)
{
	uint32_t	size = (sizex*sizey)*3;//-- 由于是24为BMP位图,一个像素占3个字节,所以要乘以3
	uint16_t	Header_num = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
	int16_t 	i = 0,j = 0,temp = 0,count = 0;
	uint16_t 	Buffer_num = 510;


	BITMAPFILEHEADER 	 BmpFileHeader;
	BITMAPINFOHEADER	 BmpInfoHeader;
	

	/*------------------------------- 建立文件头数据 -----------------------------------------*/
	BmpFileHeader.bfType      = 0x4D42;//--文件标志.只对'BM',用来识别BMP位图类型
	BmpFileHeader.bfSize 	  = size + Header_num;//--文件大小,占四个字节
	BmpFileHeader.bfReserved1 = 0;				  //--保留字段1
	BmpFileHeader.bfReserved2 = 0;				  //--保留字段2
	BmpFileHeader.bfOffBits   = Header_num;//--从文件开始到位图数据(bitmap data)开始之间的的偏移量
	/*------------------------------- 建立文件信息数据 ---------------------------------------*/
	BmpInfoHeader.biSize   = sizeof(BITMAPINFOHEADER);//--说明BITMAPINFOHEADER结构所需要的字数
	BmpInfoHeader.biWidth  = sizex;   //--说明图象的宽度,以象素为单位
	BmpInfoHeader.biHeight = sizey;   //--说明图象的高度,以象素为单位 
	BmpInfoHeader.biPlanes = 1;	      //--为目标设备说明位面数,其值将总是被设为1
	BmpInfoHeader.biBitCount = 24;    //--说明比特数/象素,其值为1、4、8、16、24、或32
	BmpInfoHeader.biCompression = 0;  //--说明图象数据压缩的类型,无压缩
	BmpInfoHeader.biSizeImage = size; //--说明图象的大小(必须是4的倍数),以字节为单位。
										//--当用BI_RGB格式时,可设置为0 
	BmpInfoHeader.biXPelsPerMeter = 0;//--说明水平分辨率,用象素/米表示
	BmpInfoHeader.biYPelsPerMeter = 0;//--说明垂直分辨率,用象素/米表示
	BmpInfoHeader.biClrUsed		  = 0;//--说明位图实际使用的彩色表中的颜色索引数
	BmpInfoHeader.biClrImportant  = 0;//--说明对图象显示有重要影响的颜色索引的数目,如果是0,表示都重要
	/*-------------------------- 创建保存截图数据的文件  ------------------------------------*/
	if (f_open(&FileSave,Save_Path, FA_WRITE|FA_CREATE_ALWAYS) == FR_OK ) 
	{	
			//--先写图像头数据和图像信息数据
			result = f_write (&FileSave,&BmpFileHeader,sizeof(BmpFileHeader),&bw);
			if (result != FR_OK)
			{
				return;
			}
			
			result = f_write (&FileSave,&BmpInfoHeader,sizeof(BmpInfoHeader),&bw);
			if (result != FR_OK)
			{
				return;
			}
			for(j = sizey-1; j >= 0; j--)
			{		 	
					 for(i = 0; i < sizex; i++)
					 {
							temp = LCD_GetPixel(startx+i,starty+j);
							data[count+2] = (u8)((temp&0xf800)>>8);
							data[count+1] = (u8)((temp&0x7e0)>>3);
							data[count]   = (u8)((temp&0x1f)<<3);
							count += 3;
							if(count == Buffer_num)
							{
									count = 0;
									result = f_write (&FileSave,data,Buffer_num,&bw);
									if (result != FR_OK)
									{
										return;
									}		
							}
					 }
			}
		if(count > 0)	f_write (&FileSave,data,count,&bw);
		f_close(&FileSave);			
     }