Fdmemtable 内存表保存图片的例子
2022/6/30 5:22:20
本文主要是介绍Fdmemtable 内存表保存图片的例子,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 var 2 aStream: TMemoryStream; 3 LDataSet: TFDDataSet; // 申请一个FD数据集 4 MyStream: Tmemorystream; 5 MyJPEG: TJpegImage; 6 MyPng: TPngImage; 7 begin 8 inherited; 9 if img2.Picture.Graphic = nil then 10 begin 11 Application.MessageBox('没有图片可以增加!!', '提示', MB_OK + MB_ICONWARNING + MB_TOPMOST); 12 13 end 14 else 15 begin 16 aStream := TMemoryStream.Create(); 17 MyStream := TMemoryStream.Create(); 18 try 19 img2.Picture.SaveToStream(aStream); 20 fdmtPicture.Append; 21 fdmtPicture.FieldByName('p_picture_id').AsLargeInt := getSnowflake; 22 fdmtPicture.FieldByName('p_picture_guid').AsString := GetGUID; 23 fdmtPicture.FieldByName('p_products_id').AsLargeInt := aid; 24 fdmtPicture.FieldByName('p_picture_name').AsString := EditImageName.Text; 25 if img2.Picture.Graphic is TJPEGImage then 26 begin 27 MyJPEG := TJpegImage.Create; 28 MyJPEG.Assign(img2.Picture.Graphic); 29 MyJPEG.CompressionQuality := 10; 30 MyJPEG.Compress; 31 MyJPEG.SaveToStream(MyStream); 32 end; 33 if img2.Picture.Graphic is TPngImage then 34 begin 35 MyPng := TPngImage.Create; 36 MyPng.Assign(img2.Picture.Graphic); 37 MyPng.CompressionLevel := 9; 38 MyPng.SaveToStream(MyStream); 39 end; 40 MyStream.Position := 0; 41 TBlobField(fdmtPicture.FieldByName('p_picture_thumbnail')).LoadFromStream(MyStream); 42 aStream.Position := 0; 43 TBlobField(fdmtPicture.FieldByName('p_picture_image')).LoadFromStream(aStream); 44 fdmtPicture.Post; 45 img2.Picture.Graphic := nil; 46 finally 47 MyStream.free; 48 aStream.Free; 49 end; 50 end;
这篇关于Fdmemtable 内存表保存图片的例子的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南