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

📄 unit1.cpp

📁 在 BC++ 编译,原代码字模提取程序,可以使用在单片机和液晶自己编程等等.
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                 case      15:count =0x2;     break;
                 case      16:count =0x1;     break;
                 }

        for   (n=1; n<17; n++)
        {
              switch (n)
              {
                 case       1:canshu =0x8000;  break;
                 case       2:canshu =0x4000;  break;
                 case       3:canshu =0x2000;  break;
                 case       4:canshu =0x1000;  break;
                 case       5:canshu =0x800;   break;
                 case       6:canshu =0x400;   break;
                 case       7:canshu =0x200;   break;
                 case       8:canshu =0x100;   break;
                 case       9:canshu =0x80;    break;
                 case      10:canshu =0x40;    break;
                 case      11:canshu =0x20;    break;
                 case      12:canshu =0x10;    break;
                 case      13:canshu =0x8;     break;
                 case      14:canshu =0x4;     break;
                 case      15:canshu =0x2;     break;
                 case      16:canshu =0x1;     break;
                }

            if ((q[n] & count)!=0 )
            {
              w=w+ canshu;
             }
           }
         if(Form1->CheckBox1->Checked==true)
          {
          stemp ="0x"+IntToHex(((w&0xff00)>>8),2)+",";
          sss=sss+stemp;
          stemp= "0x"+IntToHex((w&0x00ff),2);}

        else { stemp =IntToHex(((w&0xff00)>>8),2)+"H,";
          sss=sss+stemp;
          stemp= IntToHex((w&0x00ff),2)+"H";}

        if(Form1->CheckBox2->Checked==true)
          {
                if ((m % 33)!=0 ) stemp =stemp+",";
 //       if (stemp[1]>'9')  stemp ="0"+stemp;
                sss =sss+stemp;
                if (m %8==0 ) sss =sss+char(13)+char(10);
                if (m %16==0 ) sss =sss+char(13)+char(10);
            }
        else   {
                if ((m % 33)!=0 ) stemp =stemp+",";
 //       if (stemp[1]>'9')  stemp ="0"+stemp;
                sss =sss+stemp;
                if (m %4==0 ) sss =sss+char(13)+char(10);
                if (m %16==0 ) sss =sss+char(13)+char(10);
            }

       Form1->Label5->Caption=Form1->Label5->Caption+IntToHex(Byte(i[n]),2);
       }
     }
       Form1->Memo3->Text =sss;
        fclose(fp);
 }
//---------------------------------------------------------------------------



void __fastcall TForm1::Edit2Click(TObject *Sender)
{
//        Byte i[33];
       int  j;
       Byte p[33];
       long q[17];
       String k,st;
    char szBuffer[11];
    char ssBuffer[2];
    char mm;
       Word w;
       long count;
       int n;
       int  num; 
       int m;
       int jk;
       String sss;
       long canshu;
       String stemp;

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


        FileMode  =  0;
        k =Edit2->Text;
        edt1->Text="";
        mm= Edit2->SelStart;
        if(mm>6) mm=6;
        StrLCopy(szBuffer, Edit2->Text.c_str(), 10);
        ssBuffer[0]=szBuffer[mm];
        ssBuffer[1]=szBuffer[mm+1];

        edt1->Text=StrCat(ssBuffer, edt1->Text.c_str());
                            //(94*(qh-1)+(wh-1))*32L;
        j =((Byte(k[mm+1])-0xA1)*94+(Byte(k[mm+2])-0xA1))*32;
      fseek(fp,j,SEEK_SET);

    Memo1->Text="";
    Memo1->Text=""+ char(13)+char(10);
    Memo2->Text="";
    Memo3->Text="";
    Memo1->Lines->Add("   ");
    n =1;
    Label5->Caption ="";
    sss ="";
    fread(buf+1,32,1,fp);
    for(count =1;  count<33;  count++)
    {
        if(Form1->CheckBox1->Checked==true)
          stemp ="0x"+IntToHex(Byte(buf[n]),2);

        else  stemp =IntToHex(Byte(buf[n]),2)+"H";
        if(Form1->CheckBox2->Checked==true)
          {
                if ((n % 33)!=0 ) stemp =stemp+",";
 //       if (stemp[1]>'9')  stemp ="0"+stemp;
                sss =sss+stemp;
                if (n %16==0 ) sss =sss+char(13)+char(10);
            }
        else   {
                if ((n % 33)!=0 ) stemp =stemp+",";
 //       if (stemp[1]>'9')  stemp ="0"+stemp;
                sss =sss+stemp;
                if (n %8==0 ) sss =sss+char(13)+char(10);
            }
       Label5->Caption =Label5->Caption+IntToHex(Byte(buf[n]),2);
        n++;
        if  (n % 2==1)
        {
        Translate(Label5->Caption);
         Memo1->Lines->Add(" "+trans);
        Label5->Caption ="";
        }
     }

       Memo2->Text =sss;
      for (n =1; n<33; n++)
     {
          if (n %2==1)  p[((n+1) / 2)]  =Byte(buf[n]);
          if (n %2==0 ) p[((n) / 2)+16] =Byte(buf[n]);

     }
         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;
                 case      15:count =0x2;     break;
                 case      16:count =0x1;     break;
                 }

        for   (n=1; n<17; n++)
        {
              switch (n)
              {
                 case       1:canshu =0x8000;  break;
                 case       2:canshu =0x4000;  break;
                 case       3:canshu =0x2000;  break;
                 case       4:canshu =0x1000;  break;
                 case       5:canshu =0x800;   break;
                 case       6:canshu =0x400;   break;
                 case       7:canshu =0x200;   break;
                 case       8:canshu =0x100;   break;
                 case       9:canshu =0x80;    break;
                 case      10:canshu =0x40;    break;
                 case      11:canshu =0x20;    break;
                 case      12:canshu =0x10;    break;
                 case      13:canshu =0x8;     break;
                 case      14:canshu =0x4;     break;
                 case      15:canshu =0x2;     break;
                 case      16:canshu =0x1;     break;
                }

            if ((q[n] & count)!=0 )
            {
              w=w+ canshu;
             }
           }
         if(Form1->CheckBox1->Checked==true)
          {
          stemp ="0x"+IntToHex(((w&0xff00)>>8),2)+",";
          sss=sss+stemp;
          stemp= "0x"+IntToHex((w&0x00ff),2);
          }

        else
         {
          stemp =IntToHex(((w&0xff00)>>8),2)+"H,";
          bbuf[m]=(w&0xff00)>>8;
          bbuf[m+16]=(w&0x00ff);
          sss=sss+stemp;
          stemp= IntToHex((w&0x00ff),2)+"H";
          }

        if(Form1->CheckBox2->Checked==true)
          {
                if ((m % 33)!=0 ) stemp =stemp+",";
 //       if (stemp[1]>'9')  stemp ="0"+stemp;
                sss =sss+stemp;
                if (m %8==0 ) sss =sss+char(13)+char(10);
                if (m %32==0 ) sss =sss+char(13)+char(10);
            }
        else   {
                if ((m % 33)!=0 ) stemp =stemp+",";
 //       if (stemp[1]>'9')  stemp ="0"+stemp;
                sss =sss+stemp;
                if (m %4==0 ) sss =sss+char(13)+char(10);
                if (m %16==0 ) sss =sss+char(13)+char(10);
            }

       Form1->Label5->Caption=Form1->Label5->Caption+IntToHex(Byte(buf[n]),2);
       }
       Form1->Memo3->Text =sss;
        fclose(fp);

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




void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
     PaintBox1->Canvas->Brush->Color = clBlue;
    PaintBox1->Canvas->FillRect(PaintBox1->ClientRect);
}
//---------------------------------------------------------------------------





void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{
 //const
//    Size = 5;
//    mask =0x8000;

    int n,j;
    Word b;
   TRect arect;
   Byte b1,b2,b_conver,b_conver1;

     Image1->Canvas->Pen->Color=clWhite;
     Memo4->Text="";
     arect = Rect(0,0,Size+1,Size+1 );
     PaintBox1->Canvas->Brush->Color = clBlue ;
    PaintBox1->Canvas->Pen->Color =  clBlue;
    arect = Rect(0,0,Size - 1,Size - 1);

    for (n = 0;n<16;n++)
    {
        //一个word是一列象素
        //{转换高低位}
/*
        b1 = Byte(i[n]);
        b_conver = b1 & 0x0F;
        b_conver1 = b1 >> 4;
        b1 = b_conver1 | (b_conver << 4);
        b1 = ConvertByteEx(b1);
        b2  = Byte(i[16 + n]);
        b_conver  = b2 & 0x0F;
        b_conver1  = b2 >> 4;
        b2  = b_conver1 | (b_conver << 4);
        b2  = ConvertByteEx(b2);
 */
        b1 = Byte(bbuf[n+1]);
        b2  = Byte(bbuf[16 + n+1]);
        b = b2 | (b1 << 8);
         Memo4->Lines->Add(IntToHex(b,4));
        for (j = 0; j< 16;j++)
        {
            if ((b & mask) == mask)
               {
                PaintBox1->Canvas->Pen->Color  = clBlack;
                Image1->Canvas->Pen->Color= clRed;
                PaintBox1->Canvas->Brush->Color  = clBlue;//clBlack;
                Image1->Canvas->Brush->Color= clRed;//clBlack;
               }
            else
              {
                PaintBox1->Canvas->Pen->Color  = clWhite;
                Image1->Canvas->Pen->Color= clWhite;
                PaintBox1->Canvas->Brush->Color  = clWhite;
                Image1->Canvas->Brush->Color= clWhite;//clBlack;
               }
            PaintBox1->Canvas->Rectangle(arect);
            Image1->Canvas->Rectangle(arect);
            OffsetRect(arect,0,Size);
            b  = b << 1;
        }
        OffsetRect(arect,Size,- Size * 16);
    }
}
//---------------------------------------------------------------------------




void __fastcall TForm1::Image1Progress(TObject *Sender,
      TProgressStage Stage, BYTE PercentDone, bool RedrawNow,
      const TRect &R, const AnsiString Msg)
{
      Image1->Canvas->Brush->Color = clBlue;
      Image1->Canvas->FillRect(Image1->ClientRect);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::PaintBox1MouseUp(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
        TRect arect;
        TColor jstr;
    int yn,xn;
   Label7->Caption="Y";
   Label8->Caption="X";
   Label7->Caption=Label7->Caption+Y;
   Label8->Caption=Label8->Caption+X;
       arect = Rect(0,0,Size+1 ,Size+1 );
     PaintBox1->Canvas->Brush->Color = clWhite ;
    PaintBox1->Canvas->Pen->Color =  clBlue;
  //   PaintBox1->Canvas->Pen->Mode= Size;
  //  PaintBox1->Canvas->FillRect(PaintBox1->ClientRect);
   yn=(Y/Size)%16;
   xn=(X/Size)%16;
   Memo4->Text=yn;
   Memo4->Text=Memo4->Text+"MM"+xn;
        if(Button==mbLeft)  jstr= clRed ;
        if(Button==mbRight)  jstr= clWhite ;
             PaintBox1->Canvas->Rectangle(arect);
            OffsetRect(arect,Size*xn-1,Size*yn-1);
  //              PaintBox1->Canvas->Pen->Color =  clBlue;//clBlack;
                PaintBox1->Canvas->Brush->Color = jstr;//clBlack;

             PaintBox1->Canvas->Rectangle(arect);
            OffsetRect(arect,Size*xn,Size*yn);
  //               PaintBox1->Canvas->Pen->Color =  jstr;//clBlack;
                PaintBox1->Canvas->Brush->Color = jstr;//clBlack;
             
}
//---------------------------------------------------------------------------


void __fastcall TForm1::FormCreate(TObject *Sender)
{
//  TrackBar1->LineSize=10;
  Size=TrackBar1->Position;
}
//---------------------------------------------------------------------------



void __fastcall TForm1::TrackBar1ContextPopup(TObject *Sender,
      TPoint &MousePos, bool &Handled)
{
   Size=TrackBar1->Position;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::TrackBar1Change(TObject *Sender)
{
         Size=TrackBar1->Position;
    PaintBox1->Height=16*Size;
    PaintBox1->Width= 16*Size;
         PaintBox1->Canvas->Brush->Color = clBlue;
    PaintBox1->Canvas->FillRect(PaintBox1->ClientRect);   
    Button1Click(Sender);
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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