Ver Mensaje Individual
  #5  
Antiguo 26-09-2010
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Manejando regiones se puede crear el efecto deseado:
Creamos un form con un Timage. En el Timage cargamos un bitmap y añadimos el código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

ADWord = array [0..0] of DWORD;
PADWord = ^ADWord;

var
  Form1: TForm1;


implementation

{$R *.dfm}
//---------------------------------------------------------------------------
procedure SkinControl(Control: TWinControl; bmp: TBitmap);
var
  TransparentColor: DWORD;
  rgn, rgnTemp: HRGN;
  ini, x, y: integer;
  Pixel: PADWord;
begin
  bmp.HandleType:= bmDIB;
  bmp.PixelFormat:= pf32bit;
  Control.SetBounds(Control.Left, Control.Top, bmp.Width, bmp.Height);

  TransparentColor:= PADWord(bmp.ScanLine[bmp.Height-1])[0];

  rgn:= CreateRectRgn(0, 0, Control.Width, Control.Height);
  CombineRgn(rgn, rgn, rgn, RGN_DIFF);

  for  y:=0 to bmp.Height-1 do
  begin
    Pixel:= PADWord(bmp.ScanLine[y]);
    ini:= 0;
    for x:=0 to bmp.Width-1 do
    begin
       if pixel[x] <> TransparentColor then
       begin
         rgnTemp:= CreateRectRgn(ini, y, x, y+1);
         CombineRgn(rgn, rgn, rgnTemp, RGN_OR);
         DeleteObject(rgnTemp);
         ini:= x;
       end
       else inc(ini);
    end;
  end;
  SetWindowRgn(Control.Handle, rgn, true);
  DeleteObject(rgn);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  BorderStyle:= bsNone;
  Image1.AutoSize:= false;
  Image1.Left:= 0;
  Image1.Top:= 0;
  SkinControl(self, Image1.Picture.Bitmap);

end;

end.

Saludos.
Responder Con Cita