把jpg或bmp保存为jpg: imInput为TImage类型 if Assigned(imInput.Picture.Graphic) then begin if SameText(ExtractFileExt(sFileName),'.jpg') then begin jpg := TJpegImage.Create; ms := TMemoryStream.Create; try jpg.LoadFromFile(sfileName); bmp.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0); jpg.SaveToStream(ms); (adoDataSet.FieldByName('PICTURE') as TBlobField).LoadFromStream(ms); finally ms.Free; jpg.Free; end;{try} end{if} else if ExtractFileExt(sFileName) = '.bmp' then begin jpg := TJpegImage.Create; bmp := TBitMap.Create; ms := TMemoryStream.Create; bmp.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_BitMap),0); try jpg.Assign(bmp); jpg.SaveToStream(ms); (adoDataSet.FieldByName('PICTURE') as TBlobField).LoadFromStream(ms); finally ms.Free; bmp.Free; jpg.Free; end;{try} end; end;{if} 读取jpg: m_blob := adoDataSet.CreateBlobStream(adoDataSet.FieldByName('Picture'),bmRead); m_jpeg:=TJpegImage.Create; try if m_blob.Size<>0 then begin try m_jpeg.LoadFromStream(m_blob); imInput.Picture.Assign(m_jpeg); ImInput.Refresh; except end;{try} end else imInput.Picture.Assign(nil); finally m_jpeg.Free; m_blob.Free; end;{try} end;{if} finally adoDataSet.Free; end;{try}从一个工程中copy的,给点分吧!
imInput为TImage类型 if Assigned(imInput.Picture.Graphic) then begin
if SameText(ExtractFileExt(sFileName),'.jpg') then begin
jpg := TJpegImage.Create;
ms := TMemoryStream.Create;
try
jpg.LoadFromFile(sfileName);
bmp.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0);
jpg.SaveToStream(ms);
(adoDataSet.FieldByName('PICTURE') as TBlobField).LoadFromStream(ms);
finally
ms.Free;
jpg.Free;
end;{try}
end{if}
else if ExtractFileExt(sFileName) = '.bmp' then begin
jpg := TJpegImage.Create;
bmp := TBitMap.Create;
ms := TMemoryStream.Create;
bmp.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_BitMap),0);
try
jpg.Assign(bmp);
jpg.SaveToStream(ms);
(adoDataSet.FieldByName('PICTURE') as TBlobField).LoadFromStream(ms);
finally
ms.Free;
bmp.Free;
jpg.Free;
end;{try}
end;
end;{if}
读取jpg: m_blob := adoDataSet.CreateBlobStream(adoDataSet.FieldByName('Picture'),bmRead);
m_jpeg:=TJpegImage.Create;
try
if m_blob.Size<>0 then begin
try
m_jpeg.LoadFromStream(m_blob);
imInput.Picture.Assign(m_jpeg);
ImInput.Refresh;
except
end;{try}
end
else
imInput.Picture.Assign(nil);
finally
m_jpeg.Free;
m_blob.Free;
end;{try}
end;{if}
finally
adoDataSet.Free;
end;{try}从一个工程中copy的,给点分吧!
Series1.add(载荷值,位移值);
Series1.add(载荷值,位移值);
Series1.add(载荷值,位移值);
Series1.add(载荷值,位移值);
Series1.add(载荷值,位移值);
Chart1.SaveToBitmapFile('d:\tmp.bmp');
运行出错,提示错误为:“LIST INDEX OUT OF BOUNDS”,这是什么原因啊?
begin
Series1.AddXY(1,1);
Series1.AddXY(2,2);
Series1.AddXY(3,1);
Series1.AddXY(4,2);
Chart1.SaveToBitmapFile('D:\aa.bmp');
end;