注册 登录
编程论坛 C++ Builder

bcb新人 请教高手和前辈

csharp到bcb 发布于 2010-08-25 18:25, 1434 次点击
想用image2 显示 image1的略缩图,请各位高手和前辈 指点!感激不尽!
   void __fastcall TForm6::Button1Click(TObject *Sender)
{
      int srcWidth=this->Image1->Picture->Graphic->Width;
      int srcHeight=this->Image1->Picture->Graphic->Height;

      TMemoryStream * mStream=new TMemoryStream();
      this->Image1->Picture->Graphic->SaveToStream(mStream);
      mStream->Position=0;

      BITMAPINFO* bMAPINFO=new BITMAPINFO();
      bMAPINFO->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
      bMAPINFO->bmiHeader.biWidth=srcWidth;
      bMAPINFO->bmiHeader.biHeight=srcHeight;
      bMAPINFO->bmiHeader.biPlanes=1;
      bMAPINFO->bmiHeader.biBitCount=0;
      bMAPINFO->bmiHeader.biCompression=BI_JPEG;
      bMAPINFO->bmiHeader.biSizeImage=mStream->Size;

      char* buffer=new char[mStream->Size];
      mStream->ReadBuffer(buffer,mStream->Size) ;

      StretchDIBits(this->Image2->Canvas->Handle,
                    0,0,this->Image2->Width,this->Image2->Height,
                    0,0,srcWidth,srcHeight,
                    buffer,
                    bMAPINFO,
                    DIB_RGB_COLORS,
                    SRCCOPY);
      delete mStream;
      delete[] buffer;
}
2 回复
#2
csharp到bcb2010-08-25 18:28
看看我问题在哪?
#3
jackVIII2010-11-16 19:13
有什么地方报错了吗
1