现在想读取oracle中的blob格式文件,具体一点就是存储的位图文件?不知道从何下手?高手能给出具体的代码吗?
下面是我现在的做法,位图不是存储在数据库里,而是在磁盘上,如果把位图误删除就导致程序运行出错。 BMPPATH:=ExtractFilePath(ParamStr(0))+'BMPS';
begin
pgjbmp := Tbitmap.Create;//设置位图格式、宽度、高度
pgjbmp.pixelformat := pf8bit;
pgjbmp.width := trunc(pblv * 170);
pgjbmp.height := trunc(pblh * 1000);
pgjbmp.canvas.brush.color := clwhite;
pgjbmp.canvas.fillrect(rect(0, 0, pgjbmp.width, pgjbmp.height));
end;
gjBmp := TBitmap.Create;
gjbmp.pixelformat := pf8bit;//设置位图格式
zgd := 0;
drawl := 0;
cyggd := 0;
YGGD := 0;
GGGD := 0;
for i := 1 to gjCounts do
with gjAry[i] do
begin
if gjbmpname <> '' then
begin
BmpName := gjBmpName;
BMPNAME1 := BMPNAME;
BMPNAME := BMPPATH + '\' + BMPNAME; try
gjBmp.LoadFromFile(BmpName);
if BMPNAME1 = '26.BMP' then
GGGD := gjBmp.Height;
if BMPNAME1 = '02.BMP' then
CYGGD := gjBmp.Height;
if BMPNAME1 = '01.BMP' then
YGGD := gjBmp.Height;
gjH := gjBmp.Height;
gjW := gjBmp.width;
zgd := zgd + gjh;
except
ShowMessage('没有文件' + BmpName + '!');
end;
end;
end;上面的一段如何更改下能从Oracle里读取blob类型的BMP图片?谢谢~!
下面是我现在的做法,位图不是存储在数据库里,而是在磁盘上,如果把位图误删除就导致程序运行出错。 BMPPATH:=ExtractFilePath(ParamStr(0))+'BMPS';
begin
pgjbmp := Tbitmap.Create;//设置位图格式、宽度、高度
pgjbmp.pixelformat := pf8bit;
pgjbmp.width := trunc(pblv * 170);
pgjbmp.height := trunc(pblh * 1000);
pgjbmp.canvas.brush.color := clwhite;
pgjbmp.canvas.fillrect(rect(0, 0, pgjbmp.width, pgjbmp.height));
end;
gjBmp := TBitmap.Create;
gjbmp.pixelformat := pf8bit;//设置位图格式
zgd := 0;
drawl := 0;
cyggd := 0;
YGGD := 0;
GGGD := 0;
for i := 1 to gjCounts do
with gjAry[i] do
begin
if gjbmpname <> '' then
begin
BmpName := gjBmpName;
BMPNAME1 := BMPNAME;
BMPNAME := BMPPATH + '\' + BMPNAME; try
gjBmp.LoadFromFile(BmpName);
if BMPNAME1 = '26.BMP' then
GGGD := gjBmp.Height;
if BMPNAME1 = '02.BMP' then
CYGGD := gjBmp.Height;
if BMPNAME1 = '01.BMP' then
YGGD := gjBmp.Height;
gjH := gjBmp.Height;
gjW := gjBmp.width;
zgd := zgd + gjh;
except
ShowMessage('没有文件' + BmpName + '!');
end;
end;
end;上面的一段如何更改下能从Oracle里读取blob类型的BMP图片?谢谢~!
ADOQuery1.SQL.Text := 'insert into temp(Name, BMP) values (:Name, :BMP)';
ADOQuery1.Parameters.ParamByName('Name').Value := '1.bmp';
ADOQuery1.Parameters.ParamByName('BMP').LoadFromFile('d:\1.bmp', ftBlob);
ADOQuery1.ExecSQL;
读:var
ms: TMemoryStream;
bmp: TBitmap;
begin
ADOQuery1.Close;
ADOQuery1.SQL.Text := 'select bmp from temp where Name = ''1.bmp''';
ADOQuery1.Open;
ADOQuery1.First;
ms := TMemoryStream.Create;
TBlobField(ADOQuery1.FieldByName('BMP')).SaveToStream(ms);
ms.Position := 0;
bmp := TBitmap.Create;
bmp.LoadFromStream(ms);
ms.Free;
end;
需要定义oracle directory