Bom dia Marcos.

 

Eu uso essa função e tem funcionado bem. Ela usa como cor para definir a
transparência o primeiro pixel da imagem. Portanto defina neste pixel a cor
que você usará como transparente e deixe na mesma cor tudo o que quiser que
seja transparente.

 

Esta função estou utilizando com uma aplicação .NET Windows Forms. Se tiver
algum problema, pesquise pelo nome dela no Google que você encontrará ela
pronta para Win32.

 

Abraço.

 

function CreateRegion(Bmp: TBitmap): THandle; unsafe;

var

  X, Y, StartX:Integer;

  Excl: THandle;

  Row: PRGBArray;

  TransparentColor: TRGBTriple;

begin

  // Change the format so we know how to compare 

  // the colors 

  Bmp.PixelFormat := pf24Bit;

    

  // Create a region of the whole bitmap 

  // later we will take the transparent   

  // bits away

  Result := CreateRectRGN(0, 0, Bmp.Width, Bmp.Height);

 

  // Loop down the bitmap   

  for Y := 0 to Bmp.Height - 1 do

  begin

    // Get the current row of pixels

    Row := Bmp.Scanline[Y].ToPointer;

 

    // If its the first get the transparent

    // color, it must be the top left pixel

    if Y = 0 then

    begin

      TransparentColor := Row[0];

    end;

 

    // Reset StartX (-1) to indicate we have

    // not found a transparent area yet

    StartX := -1;

 

    // Loop across the row

    for X := 0 to Bmp.Width do

    begin

 

      // Check for transparency by comparing the color

      if(X <> Bmp.Width) and

        (Row[X].rgbtRed = TransparentColor.rgbtRed) and

        (Row[X].rgbtGreen = TransparentColor.rgbtGreen) and

        (Row[X].rgbtBlue = TransparentColor.rgbtBlue) then

      begin

        // We have (X <> Bmp.Width) in the clause so that

        // when we go past the end of the row we we can

        // exclude the remaining transparent area (if any)

        // If its transparent and the previous wasn't

        // remember were the transparency started

        if StartX = -1 then

        begin

          StartX := X;

        end;

      end

      else

      begin

        // Its not transparent

        if StartX > -1 then

        begin

          // If previous pixels were transparent we

          // can now exclude the from the region

          Excl := CreateRectRGN(StartX, Y, X, Y + 1);

          try

            // Remove the exclusion from our original region

            CombineRGN(Result, Result, Excl, RGN_DIFF);

 

            // Reset StartX so we can start searching

            // for the next transparent area

            StartX := -1;

          finally

            DeleteObject(Excl);

          end;

     end;

      end;

    end;

  end; 

end;

 

  _____  

Claudiney Cogo
N2 Sistemas e Soluções em Informática
Av. São Paulo, 172 - 15º Andar - Sala 1505
Fone/Fax: (44) 3029-6053 - Maringá - Paraná
 <http://www.n2solutions.com.br/> www.n2solutions.com.br
 <http://www.nfe.n2solutions.com.br/> www.nfe.n2solutions.com.br
 <http://www.studion2.com.br/> www.studion2.com.br

 

De: delphi-br@yahoogrupos.com.br [mailto:delphi...@yahoogrupos.com.br] Em
nome de marcosdiasvendramini
Enviada em: segunda-feira, 2 de agosto de 2010 09:16
Para: delphi-br@yahoogrupos.com.br
Assunto: [delphi-br] - Form Transparente

 

  

Bom dia pessoal.

Eu estou fazendo um formulário e quero colocar uma imagem PNG no fundo para
ficar como se fosse um Skin.

Eu tenho um componente que faz isso, mas somente com BMP, mas não fica bom,
pois a imagem perde definição e fica muito serrilhada.

Eu testei o GWL_EXSTYLE da API do windows, fica ótimo com a imagem PNG, mas
usando isso, todos os componentes ficam invisíveis e preciso que a tela
tenho alguns edit e botões.

Alguem conhece alguma forma de fazer isso.

Obrigado

---------------------------------
Marcos Dias Vendramini - MDV
http://mdv.omegasistemas.com.br
marcosdiasvendram...@yahoo.com.br
<mailto:marcosdiasvendramini%40yahoo.com.br> 





[As partes desta mensagem que não continham texto foram removidas]

Responder a