?? display.c
字號:
else if(bcolor != NO_BACK_COLOR) // 背景像素(若有背景色) PutPixel(x+(i%2)*8+j,y+(i/2),bcolor); value <<= 1; } }}//ShowChar1616()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 顯示16*24字符.// 描述: 從字庫提取點陣, 顯示一個16*24字符.//// [參數表]// addr: 字符點陣地址.// x, y: 顯示坐標.// fcolor: 前景顏色.// bcolor: 背景顏色.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void ShowChar1624(int addr,WORD x,WORD y,WORD color,int bcolor){ short i,j; BYTE value; j = 0; for( i=0; i<48; i++ ) // 16*24點陣共占48字節 { value = *(BYTE *)(addr+i); // 取8-bit點陣 for(j=0;j<8;j++) { if( value & 0x80 ) // 前景/背景判別 PutPixel(x+(i%2)*8+j,y+(i/2),color); // 前景像素 else if(bcolor != NO_BACK_COLOR) // 背景像素(若有背景色) PutPixel(x+(i%2)*8+j,y+(i/2),bcolor); value <<= 1; } }}//ShowChar1624()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 顯示24*24字符.// 描述: 從字庫提取點陣, 顯示一個24*24字符.//// [參數表]// addr: 字符點陣地址.// x, y: 顯示坐標.// fcolor: 前景顏色.// bcolor: 背景顏色.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void ShowChar2424(int addr,WORD x,WORD y,WORD color,int bcolor){ short i,j; BYTE value; j = 0; for( i=0; i<72; i++ ) // 24*24點陣共占72字節 { value = *(BYTE *)(addr+i); // 取8-bit點陣 for(j=0;j<8;j++) { if( value & 0x80 ) // 前景/背景判別 PutPixel(x+(i%3)*8+j,y+(i/3),color); // 前景像素 else if(bcolor != NO_BACK_COLOR) // 背景像素(若有背景色) PutPixel(x+(i%3)*8+j,y+(i/3),bcolor); value <<= 1; } }}//ShowChar2424()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 顯示24*32字符.// 描述: 從字庫提取點陣, 顯示一個24*32字符.//// [參數表]// addr: 字符點陣地址.// x, y: 顯示坐標.// fcolor: 前景顏色.// bcolor: 背景顏色.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void ShowChar2432(int addr,WORD x,WORD y,WORD color,int bcolor){ short i,j; BYTE value; j = 0; for( i=0; i<96; i++ ) // 24*32點陣共占96字節 { value = *(BYTE *)(addr+i); // 取8-bit點陣 for(j=0; j<8; j++) { if( value & 0x80 ) // 前景/背景判別 PutPixel(x+(i%3)*8+j,y+(i/3),color); // 前景像素 else if(bcolor != NO_BACK_COLOR) // 背景像素(若有背景色) PutPixel(x+(i%3)*8+j,y+(i/3),bcolor); value <<= 1; } }}//ShowChar2432()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 顯示32*32字符.// 描述: 從字庫提取點陣, 顯示一個32*32字符.//// [參數表]// addr: 字符點陣地址.// x, y: 顯示坐標.// fcolor: 前景顏色.// bcolor: 背景顏色.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void ShowChar3232(int addr,WORD x,WORD y,WORD color,int bcolor){ short i,j; BYTE value; j = 0; for( i=0; i<128; i++ ) // 32*32點陣共占128字節 { value = *(BYTE *)(addr+i); // 取8-bit點陣 for(j=0;j<8;j++) { if( value & 0x80 ) // 前景/背景判別 PutPixel(x+(i%4)*8+j,y+(i/4),color); // 前景像素 else if(bcolor != NO_BACK_COLOR) // 背景像素(若有背景色) PutPixel(x+(i%4)*8+j,y+(i/4),bcolor); value <<= 1; } }}//ShowChar3232()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 顯示32*48字符.// 描述: 從字庫提取點陣, 顯示一個32*48字符.//// [參數表]// addr: 字符點陣地址.// x, y: 顯示坐標.// fcolor: 前景顏色.// bcolor: 背景顏色.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void ShowChar3248(int addr,WORD x,WORD y,WORD color,int bcolor){ short i,j; BYTE value; j = 0; for( i=0; i<192; i++ ) // 32*48點陣共占192字節 { value = *(BYTE *)(addr+i); // 取8-bit點陣 for(j=0;j<8;j++) { if( value & 0x80 ) // 前景/背景判別 PutPixel(x+(i%4)*8+j,y+(i/4),color); // 前景像素 else if(bcolor != NO_BACK_COLOR) // 背景像素(若有背景色) PutPixel(x+(i%4)*8+j,y+(i/4),bcolor); value <<= 1; } }}//ShowChar3248()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 顯示32*64字符.// 描述: 從字庫提取點陣, 顯示一個32*64字符.//// [參數表]// addr: 字符點陣地址.// x, y: 顯示坐標.// fcolor: 前景顏色.// bcolor: 背景顏色.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void ShowChar3264(int addr,WORD x,WORD y,WORD color,int bcolor){ short i,j; BYTE value; j = 0; for( i=0; i<256; i++ ) // 32*64點陣共占256字節 { value = *(BYTE *)(addr+i); // 取8-bit點陣 for(j=0;j<8;j++) { if( value & 0x80 ) // 前景/背景判別 PutPixel(x+(i%4)*8+j,y+(i/4),color); // 前景像素 else if(bcolor != NO_BACK_COLOR) // 背景像素(若有背景色) PutPixel(x+(i%4)*8+j,y+(i/4),bcolor); value <<= 1; } }}//ShowChar3264()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 顯示48*80字符.// 描述: 從字庫提取點陣, 顯示一個48*80字符.//// [參數表]// addr: 字符點陣地址.// x, y: 顯示坐標.// fcolor: 前景顏色.// bcolor: 背景顏色.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void ShowChar4880(int addr,WORD x,WORD y,WORD color,int bcolor){ short i,j; BYTE value; j = 0; for( i=0;i<480;i++ ) // 48*80點陣共占480字節 { value = *(BYTE *)(addr+i); // 取8-bit點陣 for(j=0;j<8;j++) { if( value & 0x80 ) // 前景/背景判別 PutPixel(x+(i%6)*8+j,y+(i/6),color); // 前景像素 else if(bcolor != NO_BACK_COLOR) // 背景像素(若有背景色) PutPixel(x+(i%6)*8+j,y+(i/6),bcolor); value <<= 1; } }}//ShowChar4880()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 顯示字符串.// 描述: 在屏幕特定區域顯示字符串(包括英文和中文).//// [參數表]// s: 字符串首地址.// x, y: 顯示區左上角的坐標.// fcolor: 前景(字體)顏色.// bcolor: 背景顏色.// cfont: 字體大小.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void ShowString(char *s,WORD x,WORD y,WORD fcolor,int bcolor,BYTE cfont){ int i=0,j; WORD cCharSize,VSize; VSize = 16; GetCharSize(cfont,(WORD *)&cCharSize,(WORD *)&VSize); j = strlen(s); // 字符串長度 while(i<j) { if( s[i]==255 ) s[i] = 46;//浮點數的小數點 if( (s[i]<128) && (s[i] > 0)) { if(x + cCharSize > SCREEN_WIDTH) //達到屏幕右邊界 { //顯示移動到下一行 x = 0; y += LineHeight; //下一行+2個點 if (y + VSize > SCREEN_HEIGHT) break; } ShowEnglishChar(s[i++],x,y,fcolor,bcolor,cfont); if(s[i - 1] == 46) x += cCharSize/2 + 1; else x += cCharSize; // 英文都是8*16或8*12 } else { if(x + 24 > SCREEN_WIDTH) //達到屏幕右邊界 { //顯示移動到下一行 x = 0; y += LineHeight;//下一行+2個點 if (y + 24 > SCREEN_HEIGHT) break; } ShowChineseChar24(s+i,x,y,fcolor,bcolor); x += 24; //漢字為24*24 i += 2; } }}//ShowString()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 顯示信息.// 描述: 顯示信息,延時若干ms后返回.//// [參數表]// cmsg: 中文信息字符串始地址.// emsg: 英文信息字符串始地址.// wait: 延時的毫秒數//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void ShowMsg(char *cmsg, char *emsg, DWORD wait){ int i; // 計算字符串所占長度(左右留空共14個點) if(cLanguage == SHOW_CHINESE) // 語言選擇 i = (strlen(cmsg) * 12 + 14); else i = (strlen(emsg) * 12 + 14); i /= 2; SaveCurrScreen(TEMP_LZMA_ADDR); // 保存當前屏幕 // 填充一個矩形塊作為背景 FilledRectangle(SCREEN_WIDTH/2-i,SCREEN_HEIGHT/2-18,SCREEN_WIDTH/2+i-1,SCREEN_HEIGHT/2+18,COLOR_BLACK,COLOR_BLACK); // 畫邊框 Rectangle(SCREEN_WIDTH/2-i+4,SCREEN_HEIGHT/2-15,SCREEN_WIDTH/2+i-4,SCREEN_HEIGHT/2+15,COLOR_WHITE,cLine); if( cLanguage == SHOW_CHINESE ) // 根據語言選擇顯示字符串 ShowString(cmsg,SCREEN_WIDTH/2-i+6,SCREEN_HEIGHT/2-12,COLOR_WHITE,COLOR_BLACK,3); else ShowString(emsg,SCREEN_WIDTH/2-i+6,SCREEN_HEIGHT/2-12,COLOR_WHITE,COLOR_BLACK,3); while(wait-->0) // 延時 udelay(1000); // delay 1 us RestoreScreen(TEMP_LZMA_ADDR); // 恢復屏幕}//ShowMsg()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 填充矩形.// 描述: 在屏幕指定區域填充一個矩形.//// [參數表]// x1, y1: 左上角坐標// x2, y2: 右下角坐標// color1: 邊框顏色// color2: 填充顏色//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void FilledRectangle(WORD x1,WORD y1,WORD x2,WORD y2,WORD color1,WORD color2){ int i,j; WORD *addr; Rectangle(x1, y1, x2, y2, color1, cLine); // 畫邊框 for (i=y1+1; i<y2;i++) // 填充 { addr = (WORD *)(CONFIG_SM501_MEM_BASE+i*SCREEN_WIDTH*2+(x1+1)*2); for (j=x1+1; j<x2; j++) *addr++=color2; }}//FilledRectangle()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 畫圓.// 描述: 在屏幕指定位置畫圓.//// [參數表]// x, y: 圓心坐標.// radius: 半徑.// color: 顏色.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void Circle(WORD x, WORD y, WORD radius, WORD color){ int start,end,tmp,y1,y2; start = x - radius; // 起始橫坐標 if( start < 0 ) // 超出左邊,則以左邊為起始 start = 0; end = x + radius; // 結束橫坐標 if( end >= SCREEN_WIDTH ) // 超出右邊,則以右邊為結束 end = SCREEN_WIDTH - 1; y1 = y; y2 = y; while( start <= end ) // 從左右兩邊同時畫圓 { tmp = Sqrt(radius*radius-(start-x)*(start-x)); if( y+tmp < SCREEN_HEIGHT ) { if( y1 != y+tmp ) Line(start,y1,start,y+tmp,color,cLine); else PutPixel(start,y1,color); y1 = y+tmp; } if( y-tmp >= 0 ) { if( y2 != y-tmp ) Line(start,y2,start,y-tmp,color,cLine); else PutPixel(start,y2,color); y2 = y-tmp; } start = start+1; } // while(start<=end)}//Circle()//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// 函數: 畫圓.// 描述: 在屏幕指定位置畫圓, 并可設定填充.//// [參數表]// x, y: 圓心坐標.// radius: 半徑.// color: 顏色.// fill: 填充標記. 0-無填充; 1-填充.//// 注: 與FillCircle函數相比, 此函數的填充速度較快.//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~void DrawCircle(WORD x, WORD y, WORD radius,WORD color,BYTE fill){ int start,end,tmp,y1,y2; WORD i = 0,j = 0; WORD *dot; dot = (WORD *)BMP_TMPRAM_ADDR; i = 0; start = x - radius; // 起始橫坐標 if( start<0 ) // 超出左邊,則以左邊為起始 start = 0; end = x;// + radius; if( end >= SCREEN_WIDTH ) //超出右邊,以右邊為結束 end = SCREEN_WIDTH - 1; y1 = y; y2 = y; while(start <= end) { tmp = Sqrt(radius*radius-(start-x)*(start-x)); if( y+tmp < SCREEN_HEIGHT ) { if(fill == 0) { if( y1 != y+tmp ) { Line(start,y1,start,y+tmp,color,cLine); Line(start+2*(radius-i),y1,start+ 2*(radius-i),y+tmp,color,cLine); } else { PutPixel(start,y1,color); PutPixel(start+ 2*(radius-i),y1,color); } } y1 = y+tmp; } if( y-tmp >= 0 ) { if(fill == 0) { if( y2 != y-tmp ) { Line(start,y2,start,y-tmp,color,cLine); Line(start+ 2*(radius-i),y2,start+ 2*(radius-i),y-tmp,color,cLine); } else { PutPixel(start,y2,color); PutPixel(start+ 2*(radius-i),y2,color); } } y2 = y-tmp; } if(fill == 1) // 填充參數計算 { dot[j++] = start; dot[j++] = y2; dot[j++] = start; dot[j++] = y1; dot[j++] = start+ 2*(radius-i); dot[j++] = y2; dot[j++] = start+ 2*(radius-i); dot[j++] = y1; } start = start+1; i++; }//while(start<=end) if(fill == 1) // 填充圓 { for(i = 0;i<j;) { DrawLine(dot[i],dot[i+1],dot[i+2],dot[i+3],color); DrawLine(dot[i+4],dot[i+5],dot[i+6],dot[i+7],color); i += 8;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -