Ver Mensaje Individual
  #2  
Antiguo 25-06-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
Un proyecto con tres TImage un Edit y un botón.
Los TImage deben tener una imagen cargada previa.

Código:
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"


// IMPORTANTE:
// Para poder usar la función AlphaBlend del API tenemos que añadir
// msimg32.lib al proyecto:
// Añadir "$(BCB)\lib\PSDK" al library path en opciones de proyecto.

#pragma link "msimg32.lib"

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  BLENDFUNCTION xBlend;
  int ini,iAncho,iAlto,Alpha;
  Graphics::TBitmap *aBitmap1, *aBitmap2, *aBitmap3;

  iAncho = Image1->Width;
  iAlto = Image1->Height;
  aBitmap1 = new Graphics::TBitmap;
  aBitmap2 = new Graphics::TBitmap;
  aBitmap3 = new Graphics::TBitmap;
  aBitmap1->Assign(Image1->Picture->Graphic);
  aBitmap2->Assign(Image2->Picture->Graphic);
  aBitmap3->Width = iAncho;
  aBitmap3->Height =iAlto;
  ini = GetTickCount();
  aBitmap3->Assign(aBitmap1);
  xBlend.BlendOp = AC_SRC_OVER;
  xBlend.BlendFlags = 0;
  Alpha = StrToInt(Edit1->Text);
  xBlend.SourceConstantAlpha = Alpha;
  xBlend.AlphaFormat = 0;
  AlphaBlend(aBitmap3->Canvas->Handle,0,0,iAncho,iAlto,aBitmap2->Canvas->Handle,0,0,iAncho,iAlto,xBlend);
  Image3->Canvas->Draw(0,0,aBitmap3);
  Caption = IntToStr(GetTickCount() - ini)+" milisegundos por frame " + IntToStr(Alpha);
}
//---------------------------------------------------------------------------
Saludos.
Responder Con Cita