TImage->Picture->Bitmap->LoadFromStream怎么没有效果?
TImage->Picture->Bitmap->LoadFromStream怎么没有效果?
我写了个测试程序,有两个Image控件Image1, Image2.
TMemoryStream msStream;
msStream = new TMemoryStream();
//在Image1里画图
Image1->Canvas->TextOutA(10, 10, "画图");
Image1->Canvas->Pen->Color = clRed;
Image1->Canvas->Ellipse(50, 50, 200, 200);
然后将图保存到内存流中
Image1->Picture->Bitmap->SaveToStream(msStream);
我想在Image2中显示与Image1一样的
Image2->Picture->Bitmap->LoadFromStream(msStream);
没反应,怎么回事?
如果我通过文件的保存和运载是可以成功的
Image1->Picture->Bitmap->SaveToFile("aaa.bmp");
Image2->Picture->Bitmap->LoadFromFile("aaa.bmp");
为什么用内存流就不能成功?
[解决办法]
msStream->Seek(0,soFromBeginning);//加上这句话
Image2->Picture->Bitmap->LoadFromStream(msStream);