我现在导入一幅图片,要将此图的某一种颜色设置为透明色,请问怎么实现?
请各位大侠指点。

解决方案 »

  1.   

    procedure TForm1.handleClick(Sender: TObject);
    var
        p: PByteArray;
        x, y: Integer;
        Bmp: TBitmap;
    begin
        Bmp := TBitmap.Create;
        Bmp.Assign(Image1.Picture.Bitmap);
        Bmp.PixelFormat := pf24Bit;
        for y := 0 to Bmp.Height - 1 do
        begin
            p := Bmp.scanline[y];
            for x := 0 to Bmp.Width - 1 do
            begin
                //确定阀值为128
                if (p[x * 3] < 246) and (p[x * 3] > 128) and (p[x * 3 + 1] >
                    128)
                    and (p[x * 3 + 1] < 246)
                    and (p[x * 3 + 2] > 128) and (p[x * 3 + 2] < 246) then
                begin
                    p[x * 3] := p[x * 3] + 10;
                    p[x * 3 + 1] := p[x * 3 + 1] + 10;
                    p[x * 3 + 2] := p[x * 3 + 2] + 10;
                end;
                if (p[x * 3] > 10) and (p[x * 3] < 128) and (p[x * 3 + 1] >
                    10)
                    and (p[x *
                    3 + 1] < 128)
                    and (p[x * 3 + 2] > 10) and (p[x * 3 + 2] < 128) then
                begin
                    p[x * 3] := p[x * 3] - 10;
                    p[x * 3 + 1] := p[x * 3 + 1] - 10;
                    p[x * 3 + 2] := p[x * 3 + 2] - 10;
                end;
            end;
        end;
        Image2.Picture.Bitmap.Assign(Bmp);
        Bmp.Free;
    end;
      

  2.   

    图像透明Image自己就有这个属性的
    Tbitmap有关的属性:
      1.TansparentColor: 透明色;
      

  3.   

    lyguo(愚人(每天顶几顶挣分升星星)) ,TansparentColor怎么用呀?我试了一下没用。而且我只需要设置图形中的一个颜色为透明色,怎么作?
      

  4.   

    flysky_yzu(天中天) ,你写的我还没看明白,还得想想才行。多谢了!
      

  5.   

    纯紫色($FF00FF)可以,然后Image.Transparent:= True;
      

  6.   

    http://community.csdn.net/Expert/topic/3865/3865462.xml?temp=.7548334
    参看这张帖子吧