二进制图像文件转换成图片显示问题

这是一个账号007 2013-05-08 10:42:47

获取的数据流 保存在二进制的txt文件中(RGB形式)

如何把txt数据读出来 并且显示出来

实在不大会。希望知道的说详细点

真心谢谢啦。。。
...全文
132 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 1 楼 starytx 的回复:
得知道图片数据的格式
嗯 测试数据是 1M的数据 按 99 00 00 ff 存储的。99要删除。
  • 打赏
  • 举报
回复

__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
bmp = new Graphics::TBitmap;
bmp->Width =  200;
bmp->Height = 200;
bmp->PixelFormat = pf24bit;
}


void __fastcall TForm1::Button8Click(TObject *Sender)
{
 int movex=0,movey=0;
 unsigned char temp;
 int ramaddr;
 unsigned int i,j;
 unsigned char rData[120000],rtemp[120000];
 FILE *fpr;
 int BMP_Wide=200;
 int BMP_High=200;
 int linecount,pixcount,rdcount;
 int writeline;

  if((fpr=fopen("data.txt","rb"))==NULL)
   {
   Memo1-> Lines->Append("Open pcie.cap Error!");
   }
  else
   {
   Memo1-> Lines->Append("Open pcie.cap OK");
   }

  int pix;
  unsigned char rd1,rd2,rd3,rd4;
  pixcount=0;
  linecount=0;
  rdcount=0;


#if(0)    //测试读取的数据
    for(i=0;i<100;i++)
    {    rd1=getc(fpr);   rd2=getc(fpr); rd2=getc(fpr); rd4=getc(fpr);
        sprintf(outch,"%02x %02x %02x %02x",rd1,rd2,rd3,rd4);
        S= String(outch);
        Memo1-> Lines->Append(S);
    }
  fclose(fpr); return;
#endif
  bmp->Width  = BMP_Wide;
  bmp->Height = BMP_High;
  pixcount=0;
  rdcount=0;
  for(linecount=0;linecount<BMP_High;linecount++)
   {
    BYTE *ptr = (BYTE*)bmp->ScanLine[linecount];   //这里是每次循环把文件指针都放到该行的开头
    pixcount=0;
    for(i=0;i<800;i++)
    {
    if((i%4)==0)
       {
        getc(fpr);    //Del 0x99
        if(i>0) sprintf(outch,"%3d %02x %02x %02x",linecount,rData[rdcount-2],rData[rdcount-1],rData[rdcount]);
        S= String(outch);
      //  Memo1-> Lines->Append(S);   //测试读取的数据
        }
     else
       {
        rData[rdcount]=getc(fpr);  //Read BMP Data
       // if((pixcount%3)==0)   ptr[pixcount]=0xff;
       // else   ptr[pixcount]=0x00;
        ptr[pixcount] =rData[rdcount];
        pixcount++;
        rdcount++;
       }
     }
   }
 Canvas->CopyRect(ClientRect,bmp->Canvas,ClientRect); //在画布上画真彩色图片
 fclose(fpr);       
}

这有个 cbc的例子 转化成vc的时候 我没找到那些函数啊。。
starytx 2013-05-08
  • 打赏
  • 举报
回复
得知道图片数据的格式

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧