procedure AlphaBlendPanel(P: TCustomPanel;var Bmp:
TBitmap;AColor:TColor;ABlend:integer;AddFrame:boolean);

var
  b:TBitmap;


var
  bf:TBlendFunction;
  c:TCanvas;
begin

//  AColor := clInfoBk;
  fillchar(bf,sizeof(bf),0);
  b := TBitmap.Create;
  b.Height := p.Height;
  b.Width := P.Width;
  b.Canvas.Brush.Style := bsSolid;
  b.Canvas.Brush.Color := AColor;
  b.Canvas.FillRect(rect(0,0,b.Width,b.height));

  bf.BlendOp := AC_SRC_OVER;
  bf.SourceConstantAlpha := ABlend;

  BMP.Height := p.Height;
  BMP.Width := p.Width;
  p.PaintTo(bmp.Canvas,0,0);

  
windows.AlphaBlend(bmp.Canvas.Handle,0,0,P.Width,P.Height,b.Canvas.Handle,0,0,P.Width,P.Height,bf);

  if AddFrame then
  begin

    b.Canvas.Brush.Color := clNavy;
    b.Canvas.FillRect(rect(0,0,b.Width,b.height));

    bf.BlendOp := AC_SRC_OVER;
    bf.SourceConstantAlpha := 150;


 
windows.AlphaBlend(bmp.Canvas.Handle,0,0,P.Width,4,b.Canvas.Handle,0,0,P.Width,4,bf);

 
windows.AlphaBlend(bmp.Canvas.Handle,0,p.height-4,P.Width,4,b.Canvas.Handle,0,p.height-4,P.Width,4,bf);

 
windows.AlphaBlend(bmp.Canvas.Handle,0,0,4,p.height,b.Canvas.Handle,0,0,3,p.height,bf);

 
windows.AlphaBlend(bmp.Canvas.Handle,p.width-4,0,4,p.height,b.Canvas.Handle,p.width-4,0,4,p.height,bf);

  end;
{
//  BMP.Canvas.CopyMode := cmSrcAnd;
  BMP.Canvas.CopyMode := cmSrcInvert;
  BMP.Canvas.CopyRect(r,b.Canvas,r);
  BMP.Canvas.Brush.Color := clyellow;
  Dec(r.Right);
  Dec(r.Bottom);

  BMP.Canvas.FrameRect(r);
  Dec(r.Right);Dec(r.Bottom);Inc(r.Left);Inc(r.Top);
  BMP.Canvas.FrameRect(r);
 }
  b.free;

end;


On Fri, Mar 20, 2009 at 1:04 PM, Jeremy North <jeremy.no...@gmail.com>wrote:

> Delphi 2009 has support for alpha blending. Otherwise Graphics32 might
> be of some use.
>
> On Fri, Mar 20, 2009 at 10:15 AM, Jeremy Coulter <jscoul...@gmail.com>
> wrote:
> > Hi guys.
> > I need to have an overlay that does an alphablend.
> > I thought that I might be able to do this with a panel but thats no go.
> > Anyone know of a way yo acheive this?
> >
> >
> > Jeremy
> >
> > _______________________________________________
> > NZ Borland Developers Group - Delphi mailing list
> > Post: delphi@delphi.org.nz
> > Admin: http://delphi.org.nz/mailman/listinfo/delphi
> > Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
> > unsubscribe
> >
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi@delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
> unsubscribe
>



-- 
Kyley Harris
Harris Software
+64-21-671-821
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Reply via email to