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

Graphics32 元件的 transparent 效果, 圖檔去背透明蓋在底圖上

尚未結案
zombit
初階會員


發表:63
回覆:39
積分:30
註冊:2004-05-11

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-04-18 21:57:20 IP:61.62.xxx.xxx 未訂閱
我想要在 Form 的底圖上蓋一張圖檔(不規則形狀,當按鈕),    看了站上的文章有蠻多方法的, 我現在使用 Graphics32 這個元件, 他的說明中, set the DrawMode to dmBlend and call Draw or DrawTo to blend it to a background bitmap 這段我看不太懂, DrawMode to dmBlend 我了解, 不過 call Draw or DrawTo to blend, 是指要將他的 CromaKey 程式碼放在哪邊呢?    請指教,謝謝.        Q: How do I draw the bitmap with standard color key transparency?    A: Currently Graphics32 does not support color key transparency, but it is possible to preprocess the source bitmap and set its alpha buffer according to the "transparent" color:    
procedure CromaKey(ABitmap: TBitmap32; TrColor: TColor32);
var
  P: PColor32;
  C: TColor32;
  I: Integer;
begin
  TrColor := TrColor and $00FFFFFF; // erase alpha, (just in case it has some)
  with ABitmap do
  begin
    P := PixelPtr[0, 0];
    for I := 0 to Width * Height - 1 do
    begin
      C := P^ and $00FFFFFF; // get RGB without alpha
      if C = TrColor then // is this pixel "transparent"?
        P^ := C; // write RGB with "transparent" alpha back into the SrcBitmap
      Inc(P); // proceed to the next pixel
    end;
  end;
end;
Then, set the DrawMode to dmBlend and call Draw or DrawTo to blend it to a background bitmap. It is possible to use this function several times for different colors
系統時間:2024-07-01 16:19:32
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!