【正文】
tor(11 downto 0)。 variable rgb_temp1b,rgb_temp2b,rgb_temp3g,rgb_temp4b,rgb_temp5g,rgb_temp6r:std_logic_vector(3 downto 0)。 begin if mode=39。039。 then if pixel_en=39。139。 then if pixel_clk39。event and pixel_clk=39。139。 then case picture is when 0 = picture in sram if href_count515 then if rgb_state=3 then rgb_state:=0。 else rgb_state:=rgb_state+1。 end if。 case rgb_state is when 0 = read 4 byte one time,RGBR GBRG BRGB .so read 3 times while display 4 pixels SRAM_ADDR_R=SRAM_ADDR_R+1。 VGA_R=SRAM_DQ_R(11 downto 8)。 VGA_G=SRAM_DQ_R(7 downto 4)。 VGA_B=SRAM_DQ_R(3 downto 0)。 rgb_temp1b:=SRAM_DQ_R(15 downto 12)。 when 1 = SRAM_ADDR_R=SRAM_ADDR_R+1。 VGA_R=SRAM_DQ_R(7 downto 4)。 VGA_G=SRAM_DQ_R(3 downto 0)。 VGA_B=rgb_temp1b。 rgb_temp2b:=SRAM_DQ_R(11 downto 8)。 rgb_temp3g:=SRAM_DQ_R(15 downto 12)。 when 2 = SRAM_ADDR_R=SRAM_ADDR_R+1。 VGA_R=SRAM_DQ_R(3 downto 0)。 VGA_G=rgb_temp3g。 VGA_B=rgb_temp2b。 rgb_temp4b:=SRAM_DQ_R(7 downto 4)。 rgb_temp5g:=SRAM_DQ_R(11 downto 8)。 rgb_temp6r:=SRAM_DQ_R(15 downto 12)。 when 3 = VGA_R=rgb_temp6r。 VGA_G=rgb_temp5g。 VGA_B=rgb_temp4b。 when others = NULL。 end case。 else SRAM_ADDR_R=(others=39。039。)。b000100101011111111。4AFF。 VGA_R=0000。 black VGA_G=0000。 VGA_B=0000。 rgb_state:=0。 end if。 when 1 = VGA_R=1111。 white VGA_G=1111。 VGA_B=1111。 when 2 = VGA_R=0000。 blue VGA_G=0000。 VGA_B=1111。 when 3 = 18 VGA_R=1111。 red VGA_G=0000。 VGA_B=0000。 when 4 = VGA_R=0000。 green VGA_G=1111。 VGA_B=0000。 when 5 = vertical colour bar if pixel_count224 then VGA_R=1111。 VGA_G=1111。 VGA_B=1111。 elsif pixel_count304 then VGA_R=0000。 VGA_G=1111。 VGA_B=0000。 elsif pixel_count384 then VGA_R=0000。 VGA_G=0000。 VGA_B=1111。 elsif pixel_count464 then VGA_R=1111。 VGA_G=1111。 VGA_B=0000。 elsif pixel_count544 then VGA_R=0000。 VGA_G=1111。 VGA_B=1111。 elsif pixel_count624 then VGA_R=1111。 VGA_G=0000。 VGA_B=1111。 elsif pixel_count704 then VGA_R=1111。 VGA_G=0000。 VGA_B=0000。 else VGA_R=0000。 VGA_G=0000。 VGA_B=0000。 end if。 when 6 = colour changed gradually if href_count515 then RGB_add:=RGB_add+1。 VGA_R=RGB_add(3 downto 0)。 VGA_G=RGB_add(7 downto 4)。 VGA_B=RGB_add(11 downto 8)。 else RGB_add:=(others=39。039。)。 end if。 when others = horizontal colour bar if href_count155 then VGA_R=1111。 VGA_G=1000。 VGA_B=0100。 elsif href_count270 then VGA_R=1000。 VGA_G=0000。 VGA_B=1111。 elsif href_count390 then VGA_R=1111。 VGA_G=1111。 VGA_B=0000。 else VGA_R=1111。 VGA_G=0000。 VGA_B=1111。 end if。 end case。 end if。 else VGA_R=0000。 else must output 0,or there won39。t any picture on the screen VGA_G=0000。 VGA_B=0000。 end if。 end if。 end process。 end。 19 附錄 2 include unsigned char change(unsigned char t) { unsigned char ch。 if (t=9) { ch=48+t。 return(ch)。 } else { ch=t10+97。 return(ch)。 } } void main() { FILE * fpr,* fpw。 //char fr[3],fw[2],temp[3]。 int i,j,k。 unsigned char fr[6],fw[6],temp[6]。 char name[20]。 printf(please input the file39。s name:)。 scanf(%s,name)。 fpr=fopen(name,rb)。 fpw=fopen(,wt+)。 printf(Dealing\n)。 for(i=0。i480。i++) { fseek(fpr,0x36+(479i)*3*640,0)。 for(j=0。j320。j++) { fread(fr,sizeof(char),6,fpr)。 temp[0]=fr[0]4。// blue temp[1]=fr[1]4。// green temp[2]=fr[2]4。// red temp[3]=fr[3]4。// blue temp[4]=fr[4]4。// green temp[5]=fr[5]4。// red for(k=0。k6。k++) fw[k]=change(temp[k])。 fwrite(fw,sizeof(char),6,fpw)。 } } fclose(fpw)。 fclose(fpw)。 printf(finished!\n)。 }