有何圖形元件可用? |
尚未結案
|
thomas0728
中階會員 發表:112 回覆:260 積分:89 註冊:2002-03-12 發送簡訊給我 |
|
richtop
資深會員 發表:122 回覆:646 積分:468 註冊:2003-06-10 發送簡訊給我 |
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 發送簡訊給我 |
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 發送簡訊給我 |
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 發送簡訊給我 |
|
thomas0728
中階會員 發表:112 回覆:260 積分:89 註冊:2002-03-12 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |