全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:973
推到 Plurk!
推到 Facebook!

有何圖形元件可用?

尚未結案
thomas0728
中階會員


發表:112
回覆:260
積分:89
註冊:2002-03-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-09-03 01:23:00 IP:211.75.xxx.xxx 未訂閱
各位大大: 請問有何元件可以表現這個圖形,我要圓形且不要背景顏色,找了幾個二山件像都無法去背景 謝謝 如果愛情也有味覺 那麼 有沒有ㄧ種愛 微微泛酸 不太苦澀 有點甜密 嚐起來的滋味讓人想起幸福 Thomas Chiou
------
Thomas Chiou
richtop
資深會員


發表:122
回覆:646
積分:468
註冊:2003-06-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-09-03 13:41:56 IP:211.76.xxx.xxx 未訂閱
thomas0728 您好:    底下程式碼,大概能符合您的需求,您再自行修改成您要的形式。 您可將原來的圖放入 class="code">var Form1: TForm1; imgX, imgY : integer; implementation {$R *.dfm} procedure CircleCutting(image :TImage; cx, cy :integer; radius :single; allowGradient :boolean = false); var x, y, threshold : integer; sr, radius2 : single; ptr : PByteArray; begin threshold := 248; radius2 := radius*radius; image.Transparent := true; image.Picture.Bitmap.Transparent := true; image.Picture.Bitmap.TransparentColor := RGB(255,255,255); image.Picture.Bitmap.PixelFormat := pf24bit; for y:=0 to image.Picture.Height-1 do begin ptr := image.Picture.Bitmap.ScanLine[y]; for x:=0 to image.Picture.Width-1 do begin sr := (x-cx)*(x-cx) (y-cy)*(y-cy); if ( sr > radius2 ) then begin if ( allowGradient ) then begin if ( (ptr[3*x]>=threshold) and (ptr[3*x 1]>=threshold) and (ptr[3*x 2]>=threshold) ) then begin ptr[3*x ] := 255; ptr[3*x 1] := 255; ptr[3*x 2] := 255; end; end else begin ptr[3*x ] := 255; ptr[3*x 1] := 255; ptr[3*x 2] := 255; end; end; end; end; image.Refresh(); end; procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin imgX := X; imgY := Y; end; procedure TForm1.Button1Click(Sender: TObject); begin //CircleCutting(Image1, imgX, imgY, 135, true); // 容許不是白色的背景存在 CircleCutting(Image1, imgX, imgY, 135); end; RichTop 敬上 =====***** 把數學當工具,可以解決問題;將數學變能力,能夠發現並解決問題! =====#####
thomas0728
中階會員


發表:112
回覆:260
積分:89
註冊:2002-03-12

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-09-03 21:41:37 IP:61.70.xxx.xxx 未訂閱
richtop 大大你好,謝謝你的答覆, 但我有點疑問,不太了解,想在跟你請教一下 一.你所說的:先在Image1上點選圓心位置,是不是按 BUTTON 之前先按圖形中心的意 思 二. //CircleCutting(Image1, imgX, imgY, 135, true); // 容許不是白色的背景存在 CircleCutting(Image1, imgX, imgY, 135); 這二行執行的結果都一樣,整個圖形會全部不見, 不知我那裡沒搞懂 我的 IMAGE 是放在 FORM 上的一個 PANEL 上,不知這樣有問題嗎 謝謝 如果愛情也有味覺 那麼 有沒有ㄧ種愛 微微泛酸 不太苦澀 有點甜密 嚐起來的滋味讓人想起幸福 Thomas Chiou
------
Thomas Chiou
richtop
資深會員


發表:122
回覆:646
積分:468
註冊:2003-06-10

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-09-03 21:57:23 IP:211.76.xxx.xxx 未訂閱
thomas0728 您好:    
引言: richtop 大大你好,謝謝你的答覆, 但我有點疑問,不太了解,想在跟你請教一下 一.你所說的:先在Image1上點選圓心位置,是不是按 BUTTON 之前先按圖形中心的意 思 沒錯就是這個意思。 二. //CircleCutting(Image1, imgX, imgY, 135, true); // 容許不是白色的背景存在 CircleCutting(Image1, imgX, imgY, 135); 這二行執行的結果都一樣,整個圖形會全部不見, 不知我那裡沒搞懂 我的 IMAGE 是放在 FORM 上的一個 PANEL 上,不知這樣有問題嗎 謝謝 可能您用的不是.bmp格式的圖檔。所以要先將.jpg轉成.bmp,再執行。轉換程式碼如下,請參考。
procedure TForm1.Jpeg2BitmapClick(Sender: TObject);
var
   bmp : TBitmap;
begin
  bmp := TBitmap.Create;
  bmp.Width  := Image1.Picture.Width;
  bmp.Height := Image1.Picture.Height;
  bmp.Canvas.Draw(0,0,Image1.Picture.Graphic);
  Image1.Picture.Bitmap.Assign(bmp);
  bmp.Free;
end;
如果愛情也有味覺 那麼 有沒有ㄧ種愛 微微泛酸 不太苦澀 有點甜密 嚐起來的滋味讓人想起幸福 Thomas Chiou
 
 
RichTop 敬上 =====***** 把數學當工具,可以解決問題;將數學變能力,能夠發現並解決問題! =====##### 發表人 - richtop 於 2004/09/03 22:17:46
thomas0728
中階會員


發表:112
回覆:260
積分:89
註冊:2002-03-12

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-09-03 22:09:01 IP:61.70.xxx.xxx 未訂閱
大大我試出來了 原來圖形只能用 BMP 不能用 JPG 是這樣嗎 如果愛情也有味覺 那麼 有沒有ㄧ種愛 微微泛酸 不太苦澀 有點甜密 嚐起來的滋味讓人想起幸福 Thomas Chiou
------
Thomas Chiou
thomas0728
中階會員


發表:112
回覆:260
積分:89
註冊:2002-03-12

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-09-04 04:10:14 IP:61.70.xxx.xxx 未訂閱
richtop 謝謝 寫 DELPHI 程式那麼久,這次最感動,因為沒接觸過圖形處理的範圍 沒想 DELPHI 也能輕易的就處理這個問題 真是感動 如果愛情也有味覺 那麼 有沒有ㄧ種愛 微微泛酸 不太苦澀 有點甜密 嚐起來的滋味讓人想起幸福 Thomas Chiou
------
Thomas Chiou
系統時間:2024-05-17 9:57:45
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!