bcb新人 请教高手和前辈
想用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;
}