RT

解决方案 »

  1.   

    UP一个 我的SPEEDBUTTON控件自己做的图片总是有背景色,从网上下的又没有
    郁闷 ING
      

  2.   

    TBitmap 有三个属性 Transparent,TransparentMode,TransParentColor,控制背景透明***************************************************************************Indicates whether the image covers its rectangular area.property Transparent: Boolean;DescriptionUse Transparent to specify that the bitmap image be drawn transparently. The TImage component sets this property to be the same as its Transparent property to achieve transparent painting.Note: This property does not work for bitmaps that are applied to a brush. That is because the bitmap on a brush is tiled to create a texture, and hence should be rectangular. The Transparent property is typically used to create a bitmap that is not rectangular.***************************************************************************Determines whether the TransparentColor property's value is automatically calculated or stored with the bitmap object.type TTransparentMode = (tmAuto, tmFixed);
    property Transparent: TTransparentMode;DescriptionWhen TransparentMode is set to tmAuto (the default), the TransparentColor property returns the color of the bottom-leftmost pixel of the bitmap image.  When TransparentMode is set to tmFixed, the TransparentColor property refers to the color stored in the bitmap object.***************************************************************************Determines which color of the bitmap is to be transparent when the bitmap is drawn.property TransparentColor: TColor;DescriptionUse TransparentColor to determine how to draw the bitmap transparently. When the TransparentMode property is set to tmAuto (default), TransparentColor returns the color of the first pixel in the bitmap image data. For "bottom-up" bitmaps, the first pixel is the bottom leftmost pixel shown onscreen. For "top-down" bitmaps (less common), the first pixel is in the top left corner shown onscreen. If TransparentColor is assigned, the TransparentMode is automatically set to tmFixed so that the new transparent color can be used later. If you want TransparentColor to disregard any assignments and return the bottom leftmost pixel color again, set TransparentMode to tmAuto.
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      Bitmap : TBitMap;
    begin
      Bitmap := TBitmap.Create;
      try
        with Bitmap do begin
          Width := 100;
          Height := 100;
          Canvas.Brush.Color := clRed;
          Canvas.FillRect(Rect(0,0,100,100));
          Canvas.Pen.Color := clGreen;
          Canvas.MoveTo(0,0);
          Canvas.LineTo(100,100);      TransparentMode := tmFixed;
          Transparent := True;
          TransParentColor := clRed;
          Form1.Canvas.Draw(0,0,BitMap);      Transparent := False;
          Form1.Canvas.Draw(120,0,BitMap);
        end;
      finally
        Bitmap.Free;
      end;
    end;
      

  4.   

    修改你自己做的图片的左下角象素颜色为你期望的背景色,我试过了,ok!(我是用qq头像中的大力水手头像做的试验,你可以自己试一下,用windows自带的画图打开他,吧坐下角改为那种应该叫青色,一切ok!)