【问题标题】:Displaying byte values in the picturebox control在图片框控件中显示字节值
【发布时间】:2011-01-21 08:02:34
【问题描述】:

我目前正在从事一个处理读取“.0FM”格式的卫星图像的项目,其大小约为 8Mb。现在我已经成功地将文件(“*.0FM”)内容转换为字节数组。现在字节数组的整数值范围为 0 - 255。我必须在图片框控件中显示这个字节数组。下面是我实现的代码,(它运行没有错误,但没有显示任何内容......) 代码:

Bitmap^ bmp = gcnew Bitmap( 3000 , 3000 );

 long int ct = 0; //...declared as long as there are 80,00,000 elements in buf_int array
 int i,j;

 pictureBox1->Width = 3000;
 pictureBox1->Height = 3000;

for(i=0 ; i<300 ; i++)  
{  
for(j=0 ; j<300 ; j++)  
  {  
   bmp->SetPixel(i,j,Color::FromArgb((int)buf_int[ct] ));  
   pictureBox1->Image = bmp;  
   pictureBox1->Show();
   ct++;
  }

} 

请帮我解决这个问题,谢谢.....

【问题讨论】:

  • buf_int 是值为 0 - 255 的字节数组
  • 我故意将两个“for”循环设置为仅循环 90000 次(即 300 x 300),因为我想检查是否显示任何内容..循环 80 次很耗时,00,000 次...

标签: visual-studio-2008 visual-c++ .net-3.5


【解决方案1】:

我猜你已经回答了这个问题。 但是,您应该像这样重写:

bmp->SetPixel(Xcount,Ycount,Color::FromArgb((int)buf_int[ct],Color::Black));

最后一个参数是您要在缓冲区范围内更改的颜色。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-25
    • 1970-01-01
    • 1970-01-01
    • 2014-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多