IStream与TStream之间的相互转换_php技巧_脚本之家

procedureTForm1.Button1Click; var memoStream,OleStream:TStream;
Stream:IStream; begin image1.Picture:=nil; image2.Picture:=nil;
//显示初始照片 image1.Picture.LoadFromFile;
memoStream:=TmemoryStream.Create; try //将照片保存为TmemoryStream
image1.Picture.Bitmap.SaveToStream; memoStream.Position:=0;
//将TmemoryStream转成IStream stream:=TStreamAdapter.Create;
//将IStream转成TOleStream==TmemoryStream OleStream:=TOleStream.Create;
image2.Picture.Bitmap.LoadFromStream; finally memoStream.Free;
OleStream.Free; end; end; /////////////////////////// uses
………………..AxCtrls,ActiveX;//必加此二单元

TJPEGScale = (jsFullSize, jsHalf, jsQuarter,
jsEighth);//图片大小(全部,1/2,1/4,1/8)
TBitmap.pixelFormat:=pf8bit;//图片位数(8,24)

插入修改 保存图象
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;

 

保存图象 bmTemp:=TBitmap.Create;
ms:=TMemoryStream.Create; try qryFace.Close; qryFace.SQL.Clear;
qryFace.SQL.Add(update video_face_image set
face_image2=:face_imag…

给大家提供几个常用的图象格式转换方法和其转换函数
希望可以对你有帮助

  1. ICO图标转换BMP格式
  2. 32×32 BMP格式图象转换为 ICO格式
    3.转换BMP->JPEG文件格式
    4.JPEG 转换为BMP函数
    5.Bmp转换为JPEG文件格式函数
You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图