D
drmy
Unregistered / Unconfirmed
GUEST, unregistred user!
我下面这段程序是把stream的图片存到sql数据库中,然后再读出来。
问题是如果把Width和Height设得大了,显示的图片就不完整。
我觉得可能是存库的方法不对,造成了只有部分图象数据存入,所以显示不完整。
高手帮帮忙吧!最后用C++Builder。
{
IdmGrayBmp* pBitmap = new IdmGrayBmp();
int Width = 100;
int Height = 100;
LPBYTE Buf = new BYTE[Width*Height];
memset(Buf, 255, Width*Height);
pBitmap->Set(Buf, Width, Height);
Coil_Query->SQL->Clear();
Coil_Query->SQL->Add("SELECT Max(CoilID) FROM dbo.Image");
Coil_Query->Open();
DWORD dwCoilID = Coil_Query->Fields->Fields[0]->AsInteger + 1;
Coil_Query->SQL->Clear();
Coil_Query->SQL->Add("INSERT INTO dbo.Image ");
Coil_Query->SQL->Add("VALUESCoil_Id, :Image)");
Coil_Query->Params->ParamByName("Coil_Id")->AsInteger = dwCoilID;
Coil_Query->Params->ParamByName("Image")->Assign(pBitmap->GetBitmap());
if (!Coil_Query->Prepared)
{
Coil_Query->Close();
Coil_Query->Prepare();
}
Coil_Query->ExecSQL();
delete pBitmap;
delete[] Buf;
Coil_Query->SQL->Clear();
Coil_Query->SQL->Add("SELECT Image FROM dbo.Image where CoilID = " + AnsiString(dwCoilID));
Coil_Query->Open();
TStream *pStream;
pStream = Coil_Query->CreateBlobStream(Coil_Query->FieldByName("Image"), bmRead);
ImageEn1->LoadFromStream(pStream);
}
问题是如果把Width和Height设得大了,显示的图片就不完整。
我觉得可能是存库的方法不对,造成了只有部分图象数据存入,所以显示不完整。
高手帮帮忙吧!最后用C++Builder。
{
IdmGrayBmp* pBitmap = new IdmGrayBmp();
int Width = 100;
int Height = 100;
LPBYTE Buf = new BYTE[Width*Height];
memset(Buf, 255, Width*Height);
pBitmap->Set(Buf, Width, Height);
Coil_Query->SQL->Clear();
Coil_Query->SQL->Add("SELECT Max(CoilID) FROM dbo.Image");
Coil_Query->Open();
DWORD dwCoilID = Coil_Query->Fields->Fields[0]->AsInteger + 1;
Coil_Query->SQL->Clear();
Coil_Query->SQL->Add("INSERT INTO dbo.Image ");
Coil_Query->SQL->Add("VALUESCoil_Id, :Image)");
Coil_Query->Params->ParamByName("Coil_Id")->AsInteger = dwCoilID;
Coil_Query->Params->ParamByName("Image")->Assign(pBitmap->GetBitmap());
if (!Coil_Query->Prepared)
{
Coil_Query->Close();
Coil_Query->Prepare();
}
Coil_Query->ExecSQL();
delete pBitmap;
delete[] Buf;
Coil_Query->SQL->Clear();
Coil_Query->SQL->Add("SELECT Image FROM dbo.Image where CoilID = " + AnsiString(dwCoilID));
Coil_Query->Open();
TStream *pStream;
pStream = Coil_Query->CreateBlobStream(Coil_Query->FieldByName("Image"), bmRead);
ImageEn1->LoadFromStream(pStream);
}