将图片缩小后存入数据库 将图片缩小后存入数据库可以,但是在显示此图片时提示JPEG ERROR #52,请高手指教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 帮你顶啊!我听说好象先转化成BMP格式,但没试过.期待中…… 利用下面自定义函数进行压缩procedure TForm1.ZoomImage (SetWidth: integer; SetHeight: integer);var Bitmap: TBitmap; DstRect: TRect;begin { Refresh first -- needed as one maked the image really big first} Image1.Picture.Graphic.LoadFromFile(opendialog1.FileName); // Image1.Picture.LoadFromFile(opendialog1.FileName); Bitmap := TBitmap.Create; Bitmap.Width := SetWidth; Bitmap.Height := SetHeight; Bitmap.Canvas.StretchDraw(Bitmap.Canvas.ClipRect,Image1.Picture.Graphic); Image1.Picture.Graphic := Bitmap; Image1.Invalidate; //quite important...end;、、、、、、、、procedure TForm1.Button2Click(Sender: TObject); //保存图像varstrm:tmemorystream; ext:string;beginif image1.picture.Graphic <> nil then //避免image1中无图像保存出错beginext:=extractfileext(opendialog1.FileName ); //取出文件的扩展名strm := tmemorystream.Create ;tryimage1.Picture.Graphic.SaveToStream(strm);adoquery1.Edit ;strm.Position:=0;tblobfield(adoquery1.FieldByName('picture')).LoadFromStream(strm);//如需直接由文件保存可采用如下注释行 不过用上面的好些,所见即所得//TBlobField(adoquery1.FieldByName('picture')).LoadFromFile(OpenDialog1.FileName);//以下记录保存到数据库的图像格式if uppercase(ext) = '.BMP' thenadoquery1.FieldByName('isbmp').Value := 1 //BMP型图像数据else if (uppercase(ext) = '.JPG') OR ( uppercase(ext) = '.JPEG') Thenadoquery1.FieldByName('isbmp').Value := 0; //JPEG型图像数据adoquery1.Post ;finallystrm.Free ; //笔者发现如strm采用tblobstream类,程序运行到该语句会出现问题end; 借楼主宝地一用,散分:http://community.csdn.net/Expert/topic/3607/3607806.xml?temp=.9890863 一个不太难的问题,但我没明白。请教 急求图形图象方面的书籍! MS SQL SERVER 2000 安装在INTENET 中,须要开哪几个端口?如何保证安全? dll问题,如何返回string 如何将要打印的东西传到EXCL中打印?? 做不下去了:高分求解图像打印问题----分不够可以加 请问 installshield express for delphi 5.0 哪里有下载 求CDMA的资料,中文最好~~~~~~~~~ 怎么用父窗体中的控件关闭子窗体? 如何判断一个文件夹的上一级文件夹? 这个有点难度,能解决吗? 100分,请高手给一个思路~~~~顶者有分
我听说好象先转化成BMP格式,但没试过.期待中……
var Bitmap: TBitmap;
DstRect: TRect;
begin
{ Refresh first -- needed as one maked the image really big first}
Image1.Picture.Graphic.LoadFromFile(opendialog1.FileName);
// Image1.Picture.LoadFromFile(opendialog1.FileName); Bitmap := TBitmap.Create;
Bitmap.Width := SetWidth;
Bitmap.Height := SetHeight; Bitmap.Canvas.StretchDraw(Bitmap.Canvas.ClipRect,Image1.Picture.Graphic); Image1.Picture.Graphic := Bitmap;
Image1.Invalidate; //quite important...
end;
、、、、、、、、
procedure TForm1.Button2Click(Sender: TObject); //保存图像
var
strm:tmemorystream;
ext:string;
begin
if image1.picture.Graphic <> nil then //避免image1中无图像保存出错
begin
ext:=extractfileext(opendialog1.FileName ); //取出文件的扩展名
strm := tmemorystream.Create ;
try
image1.Picture.Graphic.SaveToStream(strm);
adoquery1.Edit ;
strm.Position:=0;
tblobfield(adoquery1.FieldByName('picture')).LoadFromStream(strm);
//如需直接由文件保存可采用如下注释行 不过用上面的好些,所见即所得
//TBlobField(adoquery1.FieldByName('picture')).LoadFromFile(OpenDialog1.FileName);
//以下记录保存到数据库的图像格式
if uppercase(ext) = '.BMP' then
adoquery1.FieldByName('isbmp').Value := 1 //BMP型图像数据
else if (uppercase(ext) = '.JPG') OR ( uppercase(ext) = '.JPEG') Then
adoquery1.FieldByName('isbmp').Value := 0; //JPEG型图像数据
adoquery1.Post ;
finally
strm.Free ; //笔者发现如strm采用tblobstream类,程序运行到该语句会出现问题
end;
http://community.csdn.net/Expert/topic/3607/3607806.xml?temp=.9890863