如何向SQL Server中保存bmp图象以及读取

来源:互联网 发布:数据采集系统源代码 编辑:程序博客网 时间:2024/05/22 07:42
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

插入修改 保存图象
bmTemp:=TBitmap.Create;
ms:=TMemoryStream.Create;
try
    qryFace.Close;
    qryFace.SQL.Clear;
    qryFace.SQL.Add('update video_face_image set face_image2=:face_image2');
    qryFace.SQL.Add(Format('where event_id=%d',[qryPrepare.FieldByName('event_id').AsInteger]));
    bmTemp.LoadFromFile('c:face2.bmp');
    bmTemp.SaveToStream(ms);                      
    qryFace.Parameters.ParamByName('face_image2').LoadFromStream(ms,ftBlob);
finally
    ms.Free;
    bmTemp.Free;
end;

如何在Image组件中显示
bmTemp:=TBitmap.Create;
ms:=TMemoryStream.Create;
try
    TBlobField(qryFace.FieldByName('face_image1')).SaveToStream(ms);
    ms.Position:=0;  //最最重要的一点
    bmTemp.LoadFromStream(ms);
    imgFace1.Picture.Bitmap:=bmTemp;
finally
    ms.Free;
    bmTemp.Free;
end;

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击