⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.cpp

📁 在 BC++ 编译,原代码字模提取程序,可以使用在单片机和液晶自己编程等等.
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	un.ab=n;
	un.ab-=0xa1a1;
	j=un.st.b;
	k=un.st.a;
	//************************************************
	//view
	window(1,2,16,18);//左、上、右、下
	/*
	printf("\nthe new value un.ab-0xA1A1 = %04.4x ",un.ab);
	//getch();
	printf("\nunsigned char un.st.b = %02.2x ",un.st.b);
	printf(" to  unsigned long j = %02.2lx  ",j);
	printf("\nunsigned char un.st.a = %02.2x ",un.st.a);
	printf(" to  unsigned long k = %02.2lx \n",k);
	*/
	//getch();
	//************************************************
	m=HZDZ_LEN*(j*94+k);
	//**************************************************
	//view
	/*
	printf("we get the position = 32*(%0.2x*94+%0.2X)\n",j,k);
	printf("                    = %0.2lx\n",m);
	*/
	//getch();
	//**************************************************
	if(fseek(fp,m,0))
	{
		fclose (fp);
		return 0xb020;		//读HZK12文件到结尾
	}
	for(i=0;i<HZDZ_LEN;i++)
       	hzdz[i]=fgetc(fp);
	fclose(fp);
	return (m);
}

//汉字点阵数据显示观察

void hanzi_view()
{
        char j;
	int k;
	for(char i=0;i<HZDZ_LEN;)
	{
		for(char j=0;j<8;j++)
		{
			k=7-j;
			line[j]=(hzdz[i])>>k;
			line[j]&=0x01;
		}
		i++;
		for(;j<16;j++)
		{
			k=15-j;
			line[j]=(hzdz[i])>>k;
			line[j]&=0x01;
		}
		i++;
		for(j=0;j<(HZDZ_LEN/2);j++)
		{
			if(line[j])
				Form1->Memo1->Text=printf(" 1",line[j]);
			else
				Form1->Memo1->Text=printf("  ");
		}
		cout<<endl;
	}
}


void __fastcall TForm1::Button2Click(TObject *Sender)
{
   jmain();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::CheckBox1Click(TObject *Sender)
{
  Form1->CheckBox1->Checked;
  k1=1;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)
{
   String j;
   j=Form1->Edit1->Text;
   hanzi16(j);

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)
{
        FILE *fp;
	unsigned char th = Byte(Edit1->Text[1]);
	unsigned char tl = Byte(Edit1->Text[2]);
	//开辟字库缓冲区大小,一个字节8个点
	unsigned char Libbuff[32];
	unsigned char VerLibbuff[32];
	unsigned long    address;
	unsigned char    BitIndex;
		unsigned int HorizonRow;
		unsigned int HorizonCol;
        String k;
 //       Byte ij[32];
//	CFile myfile;

	//清空显示缓冲区
//	m_HorizonLib.Empty();
//	m_VerticalLib.Empty();

	//根据汉字内码计算在文件中地址
	address = ((th-0xa1)*94+(tl-0xa1))*32;
//        address =((Byte(k[1])-0xA1)*94+(Byte(k[2])-0xA1))*32;

	//打开字库文件
//	if(!myfile.Open("HZK16",CFile::typeBinary|CFile::modeReadWrite,NULL))
        if ((fp = fopen("hzk16", "rb"))== NULL)
	{
 //		MessageBox("error");
                Form1->Memo1->Text=fprintf(fp, "Cannot open output file.\n");
//               Application->MessageBox("error",MB_OK);
		return ;
	}
	//读取字模缓冲区
//	myfile.Seek(address,CFile::begin);
        FileMode  =  0;
 //       k =Edit1->Text;
        fseek(fp,address,SEEK_SET);
//	myfile.Read(Libbuff,sizeof(Libbuff));
        fread(Libbuff,32,1,fp);

//	myfile.Close();


	//横排----->竖排
	for(char i = 0;i<32;i++)
	{
		BitIndex = 0x01;
		VerLibbuff[i] = 0;

		//找出列号
		if(i<(32>>1))
		{
			HorizonCol = i;
		}
		else
		{
			HorizonCol = i -  (32>>1);
		}
		for(int j=0;j<8;j++)
		{
			//找出行号
			if(i<(32>>1))
			{
				HorizonRow = j;
			}
			else
			{
				HorizonRow = j+8;
			}
			unsigned char temp2 = 0x80;
			//找到对应位置位
			if(Libbuff[HorizonRow*2+(HorizonCol>>3)]&(temp2>>(HorizonCol%8)))
			{
				VerLibbuff[i] = VerLibbuff[i] | BitIndex;
			}
			BitIndex = BitIndex<<1;

		}
	}
	

	//将字模显示出来
//	DisplayResult(ij,POINTER_WIDTH,POINTER_HEIGHT);

	//显示横排结果
	for(char i=0;i<32;i++)
	{
		char temp[3];
		unsigned char Value = Libbuff[i];
		if(((i%8)==0)&&(i!=0))
		{
//			m_HorizonLib += "\r\n" ;
                        Form1->Memo2->Text += "\r\n" ;
		}
//		m_HorizonLib += " 0x" ;
                Form1->Memo2->Text += " 0x" ;
		if(Value<16)
		{
			temp[0] = '0';
			itoa(Value,& temp[1],16);
		}
		else
		{

			itoa(Value,temp,16);
		}
//		m_HorizonLib += temp;
		Form1->Memo2->Text += temp;
	}

	//显示竖排结果
	for(char i=0;i<32;i++)
	{
		char temp[3];
		unsigned char Value = VerLibbuff[i];
		if(((i%8)==0)&&(i!=0))
		{
//			m_VerticalLib += "\r\n" ;
                        Form1->Memo3->Text += "\r\n" ;
		}
//		m_VerticalLib += " 0x" ;
                Form1->Memo3->Text += " 0x" ;
		if(Value<16)
		{
			temp[0] = '0';
			itoa(Value,&temp[1],16);
		}
		else
		{

			itoa(Value,temp,16);
		}
//		m_VerticalLib += temp;
                Form1->Memo3->Text += temp ;
	}

            fclose(fp);
 //	updatedata;
	//dc.GetGlyphOutline();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button5Click(TObject *Sender)
{
        FILE *fp;
        Byte buffer[32];
        int  j;
       Byte p[32];
       long q[16];
       String k;
       long count;
       int n;
       int m;
       int jk;
       String sss;
       long canshu;
    if ((fp = fopen("hzk16", "rb"))== NULL)
   {
      Form1->Memo1->Text=fprintf(fp, "Cannot open output file.\n");
      return ;
   }

        FileMode  =  0;
        k =Edit1->Text;
                           //(94*(qh-1)+(wh-1))*32L;
        j =((Byte(k[1])-0xA1)*94+(Byte(k[2])-0xA1))*32;
      fseek(fp,j,SEEK_SET);

      fread(buffer,32,1,fp);
    Memo1->Text="";
    Memo2->Text="";
    Memo3->Text="";

          for(char i=0;i<8;i++)
         {
           Memo2->Text = Memo2->Text+"0x"+IntToHex(Byte(buffer[i]),2)+",";
          }
         Memo2->Text = Memo2->Text+char(0x0d)+char(0x0a);
          for(char i=8;i<16;i++)
         {
           Memo2->Text = Memo2->Text+"0x"+IntToHex(Byte(buffer[i]),2)+",";
          }
         Memo2->Text = Memo2->Text+char(0x0d)+char(0x0a);
          for(char i=16;i<24;i++)
         {
           Memo2->Text = Memo2->Text+"0x"+IntToHex(Byte(buffer[i]),2)+",";
          }
         Memo2->Text = Memo2->Text+char(0x0d)+char(0x0a);
          for(char i=24;i<32;i++)
         {
           Memo2->Text = Memo2->Text+"0x"+IntToHex(Byte(buffer[i]),2)+",";
          }
        
}
//---------------------------------------------------------------------------




void __fastcall TForm1::Button6Click(TObject *Sender)
{
        FILE *fp;
       Byte i[129];
       int  j;
       Byte p[33];
       long q[17];
       String k,st;

       Word w;
       long count;
       int n,nb;
       int  num;
       int m;
       int jk;
       String sss;
       long canshu;
       String stemp;
       unsigned int hh,ni;

    if ((fp = fopen("HZK16", "rb"))== NULL)
   {
     MessageDlg("  字库文件没有打开 ! ",mtError, TMsgDlgButtons() << mbOK, 0);
      return ;
   }

    Memo1->Text="";
    Memo1->Text=""+ char(13)+char(10);
    Memo2->Text="";
    Memo3->Text="";
    Memo1->Lines->Add(" ");
    n =1;
    Label5->Caption ="";
    Label6->Caption ="";
    sss ="";
        FileMode  =  0;
        k =Edit2->Text;
//        nb=Edit2->Text.Length();
//       Label6->Caption =nb;
//        ni=StrToInc(Label6->Caption);
        hh=1;
     for(hh=0;hh<4;hh++)
         {
                        //(94*(qh-1)+(wh-1))*32L;
            j =((Byte(k[hh*2+1])-0xA1)*94+(Byte(k[hh*2+2])-0xA1))*32;
            fseek(fp,j,SEEK_SET);
            fread(i+hh*32+1,32,1,fp);
         }

    for(count =1;  count<129;  count++)
    {
        if(Form1->CheckBox1->Checked==true)  stemp ="0x"+IntToHex(Byte(i[n]),2);
        else  stemp =IntToHex(Byte(i[n]),2)+"H";
        if(Form1->CheckBox2->Checked==true)
          {
                if ((n % 129)!=0 ) stemp =stemp+",";
                sss =sss+stemp;
                if (n %16==0 ) sss =sss+char(13)+char(10);
                if (n %32==0 ) sss =sss+char(13)+char(10);
            }
        else   {
                if ((n % 129)!=0 ) stemp =stemp+",";
                sss =sss+stemp;
                if (n %8==0 ) sss =sss+char(13)+char(10);
                if (n %32==0 ) sss =sss+char(13)+char(10);
            }
       Label5->Caption =Label5->Caption+IntToHex(Byte(i[n]),2);
        n++;
        if  (n % 2==1)
        {
        Translate(Label5->Caption);
        Memo1->Lines->Add(" "+trans);
        Label5->Caption ="";
        }
     }
//   Memo2->Lines->Add(sss);
    Memo2->Text=sss;
       sss ="";
    for(hh=0;hh<4;hh++)
      {
      for (n =1; n<33; n++)
        {
          if (n %2==1)  p[((n+1) / 2)]  =Byte(i[n+hh*32]);
          if (n %2==0 ) p[((n) / 2)+16] =Byte(i[n+hh*32]);
         }
         for (n = 1; n<17;n++)
            {
                 q[n] =p[n]*256+p[n+16];

            }
//       sss ="";
        for (m =1;m<17;m++ )
        {
            w =0;
            switch (m)
              {
                 case       1:count =0x8000;  break;
                 case       2:count =0x4000;  break;
                 case       3:count =0x2000;  break;
                 case       4:count =0x1000;  break;
                 case       5:count =0x800;   break;
                 case       6:count =0x400;   break;
                 case       7:count =0x200;   break;
                 case       8:count =0x100;   break;
                 case       9:count =0x80;    break;
                 case      10:count =0x40;    break;
                 case      11:count =0x20;    break;
                 case      12:count =0x10;    break;
                 case      13:count =0x8;     break;
                 case      14:count =0x4;     break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -