線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:947
推到 Plurk!
推到 Facebook!

如何将BMP位图转换为指定象素?

尚未結案
plmm25
一般會員


發表:15
回覆:6
積分:4
註冊:2004-04-20

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-05-17 18:07:38 IP:220.184.xxx.xxx 未訂閱
比如有一张BMP大小为1.00MB,1024 x 768象素,我的程序用对话框读入,经过处理,我要将他缩小到200 X 200象素,大小变为0.1MB,达到缩略图的样子,以便更小的存入数据库等,变于读取,请问如何实现,谢谢大大们指点!
Chance36
版主


發表:31
回覆:1033
積分:792
註冊:2002-12-31

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-05-17 18:53:50 IP:211.20.xxx.xxx 未訂閱
請參考下列文章,有很精闢的說明 http://delphi.ktop.com.tw/topic.php?topic_id=49370 http://delphi.ktop.com.tw/topic.php?topic_id=34732 ★ http://delphi.ktop.com.tw/topic.php?topic_id=43205 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=38057 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=38124 ★ 發表人 - chance36 於 2004/05/17 19:03:11
yachanga
資深會員


發表:24
回覆:335
積分:296
註冊:2003-09-27

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-05-19 00:28:09 IP:61.230.xxx.xxx 未訂閱
這個問題好像很面熟 class="code"> function StretchImagePercent(FileName : TFileName; Percent, Quality : Integer) : TJpegImage; var bmp, tempbmp : TBitmap; RT : TRect; begin result := TjpegImage.Create; bmp := TBitmap.Create; tempbmp := TBitmap.Create; try if Uppercase(ExtractFileExt(FileName)) = '.JPG' then begin result.LoadFromFile(FileName); bmp.Width := Round(result.Width * Percent / 100); bmp.Height := Round(result.Height * Percent / 100); end else if Uppercase(ExtractFileExt(FileName)) = '.BMP' then begin tempbmp.LoadFromFile(FileName); bmp.Width := Round(tempbmp.Width * Percent / 100); bmp.Height := Round(tempbmp.Height * Percent / 100); end else exit; RT.Left := 0; RT.Top := 0; RT.Right := bmp.Width - 1; RT.Bottom := bmp.Height - 1; if Uppercase(ExtractFileExt(FileName)) = '.JPG' then bmp.Canvas.StretchDraw(RT,result) else bmp.Canvas.StretchDraw(RT,tempbmp); result.CompressionQuality := Quality; result.Assign(bmp); finally tempbmp.Free; bmp.Free; end; end; ~悠遊法國號~
killghost
一般會員


發表:14
回覆:21
積分:7
註冊:2004-04-21

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-05-24 13:56:20 IP:218.88.xxx.xxx 未訂閱
下面是我的方法将图片压缩成了160*120: Function CompressIMG(o_bitmap:Tbitmap):Tbitmap; var MaxPixW: real; MaxPixH: real; imagex: real; imagey: real; proportion:real; tempRect :TRect; n_bitmap:Tbitmap; begin n_bitmap:=TBitmap.create; MaxPixW:=o_bitmap.Width; MaxPixH:=o_bitmap.Height; imagex:=160.0; imagey:=120.0; /////////// 确定n_bitmap的宽高///////////////// proportion:=MaxPixW/MaxPixH; if proportion>=imagex/imagey then begin n_bitmap.Width:=160; n_bitmap.Height:=round(n_bitmap.Width/proportion); end else begin n_bitmap.Height:=120; n_bitmap.Width:=round(n_bitmap.Height*proportion); end; tempRect.Left:=0; tempRect.Right:=n_bitmap.Width; tempRect.Top:=0; tempRect.Bottom:=n_bitmap.Height; n_bitmap.Canvas.StretchDraw(tempRect,o_bitmap); Result:=n_bitmap; end;
系統時間:2024-05-17 16:48:27
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!