如何将JPG图像转换为bmp文件,并指定图像大小????? 现想将JPG文件保存到SQL server的image类型字段中,怎么样将jpg文件在打开时转换为bmp并指定为160X120的图片。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ///Bitmap 和 JPEG 格式间的快速转换function Bmp2Jpg(Bmp: TBitmap; Quality: Integer = 100): TJpegImage;beginResult := nil;if Assigned(Bmp)then beginResult := TJpegImage.Create;Result.Assign(Bmp); {It′s all folks...}Result.CompressionQuality := Quality;Result.JPEGNeeded; {Key method...}Result.Compress;end;end;function Jpg2Bmp(Jpg: TJpegImage): TBitmap;beginResult := nil;if Assigned(Jpg)then beginResult := TBitmap.Create;Jpg.DIBNeeded; {Key method...}Result.Assign(Jpg); {It′s all folks...}end;end; 这里有个bmp转jpg的希望对搂主有帮助procedure TForm1.Button1Click(Sender: TObject);var ExmJpeg : TJPEGImage; ExmImage : TImage; Appath : String;begin if Edit1.Text = '' then begin ShowMessage('请选择要转换的.bmp文件'); Exit; end; Appath := ExtractFileDir(Application.ExeName); ExmImage := TImage.Create(Self); ExmJpeg := TJPEGImage.Create; ExmImage.Picture.LoadFromFile(Edit1.Text); ExmJpeg.Assign(ExmImage.Picture.Bitmap); if (MessageBox(Handle,'真的转化为.jpg吗?请按确定','提示',MB_YESNO + MB_ICONINFORMATION) = idyes) then ExmJpeg.SaveToFile(Edit2.Text+'.jpg'); ExmJpeg.Free; ExmImage.Free;end; uses Graphics, JPEG;function ZoomImage(var JpegImage: TJpegImage; SetWidth: integer; SetHeight: integer);TBitmap;var BitMapTmp: TBitmap;begin JpegImage.DIBNeeded; Result:= TBitmap.Create; Result.Assign(JpegImage); JpegImage.Free; BitMapTmp := TBitmap.Create; try BitMapTmp.Assign(BitMap); Result.Width := SetWidth; Result.Height := SetHeight; Result.Canvas.StretchDraw(Result.Canvas.ClipRect, BitMapTmp); finally BitMapTmp.Free; end; end; 转换好像可以,但是怎么往sqlserver中存的时候,怎么还是存不进去呢。怎么才能把jpg文件像bmp的一样可以存进去,又可以用dbiamge显示呢? JPG可以存入SQLSERVER但要想在dbiamge中显示,就要改dbiamge控件了,还用Image控件吧! 我有bmp转换成jpeg并存到数据库的例子email:[email protected] 问题解决了,jpg转为bmp再保存。谢谢各位。 delphi webb中 按钮点击的问题 用多线称发邮件的问题 利用Table控件进行查询,结果有多条记录怎么处理? 怪事,如何在ADO用创建DBF表,并且指定数值字段的长度?急,在线等 请问如何用WebBrowser来操作类似动网论坛这些标题! fastreport怎么打印一个dbgrid中的内容? print控件 高手救命,关于ado连接sqlserver失败的问题 MDI窗体退出时提示出错?(急,一定给分) dbgird 怎么不能显示中文? 如何取消数据登陆窗口直接进入程序? 时间格式问题
procedure TForm1.Button1Click(Sender: TObject);
var
ExmJpeg : TJPEGImage;
ExmImage : TImage;
Appath : String;
begin
if Edit1.Text = '' then
begin
ShowMessage('请选择要转换的.bmp文件');
Exit;
end;
Appath := ExtractFileDir(Application.ExeName);
ExmImage := TImage.Create(Self);
ExmJpeg := TJPEGImage.Create;
ExmImage.Picture.LoadFromFile(Edit1.Text);
ExmJpeg.Assign(ExmImage.Picture.Bitmap);
if (MessageBox(Handle,'真的转化为.jpg吗?请按确定','提示',MB_YESNO + MB_ICONINFORMATION) = idyes) then
ExmJpeg.SaveToFile(Edit2.Text+'.jpg');
ExmJpeg.Free;
ExmImage.Free;
end;
Graphics, JPEG;function ZoomImage(var JpegImage: TJpegImage; SetWidth: integer; SetHeight:
integer);TBitmap;
var
BitMapTmp: TBitmap;
begin
JpegImage.DIBNeeded;
Result:= TBitmap.Create; Result.Assign(JpegImage);
JpegImage.Free;
BitMapTmp := TBitmap.Create;
try
BitMapTmp.Assign(BitMap);
Result.Width := SetWidth;
Result.Height := SetHeight;
Result.Canvas.StretchDraw(Result.Canvas.ClipRect, BitMapTmp);
finally
BitMapTmp.Free;
end;
end;
怎么才能把jpg文件像bmp的一样可以存进去,又可以用dbiamge显示呢?
email:[email protected]