 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
irlemos Guest
|
Posted: Fri Apr 27, 2007 11:56 pm Post subject: TImage blink on fade |
|
|
Hi,
I'm using BCB5...
I wrote this code based on: http://homepages.borland.com/efg2lab/ImageProcessing/Tween.htm
The code works 100% but during transition the TImage blink...
What can I do to draw without having the image to blink?
void __fastcall TForm1::Fade(int Alpha)
{
img1->Picture->Bitmap->PixelFormat = pf24bit;
img2->Picture->Bitmap->PixelFormat = pf24bit;
img3->Picture->Bitmap->PixelFormat = pf24bit;
//img2->Picture->Bitmap = NULL;
dc = CreateTweenBitmap(img1->Picture->Bitmap,100-Alpha,img3-
| Quote: | Picture->Bitmap,Alpha);
} |
//---------------------------------------------------------------------------
unsigned char __fastcall TForm1::WeightPixels(unsigned long WeightA,
unsigned long pixelA,
unsigned long WeightB,
unsigned long pixelB,
unsigned long
SumWeights)
{
unsigned char result;
result = (unsigned char)floor((WeightA * pixelA + WeightB *
pixelB) / SumWeights);
return result;
}
//---------------------------------------------------------------------------
Graphics::TBitmap * __fastcall
TForm1::CreateTweenBitmap(Graphics::TBitmap *BitmapA, unsigned long
WeightA,
Graphics::TBitmap *BitmapB, unsigned long WeightB)
{
Graphics::TBitmap *result = new Graphics::TBitmap();
const MaxPixelCount = 65536;
typedef TRGBTriple TRGBArray[MaxPixelCount];
typedef TRGBArray *pRGBArray;
TRGBTriple *RowA;
TRGBTriple *RowB;
TRGBTriple *RowTween;
int i;
int j;
unsigned long SumWeights;
SumWeights = WeightA + WeightB;
result->Width = BitmapA->Width;
result->Height = BitmapA->Height;
result->PixelFormat = pf24bit;
// If SumWeights is 0, just return a "empty" white image
i=0; j=0;
if(SumWeights > 0)
{
for(j=0; j<result->Height; j++)
{
RowA = (TRGBTriple*)BitmapA->ScanLine[j];
RowB = (TRGBTriple*)BitmapB->ScanLine[j];
RowTween = (TRGBTriple*)result->ScanLine[j];
for(i=0; i<result->Width; i++ )
{
RowTween[i].rgbtRed = WeightPixels(WeightA,
RowA[i].rgbtRed , WeightB, RowB[i].rgbtRed , SumWeights);
RowTween[i].rgbtGreen = WeightPixels(WeightA,
RowA[i].rgbtGreen, WeightB, RowB[i].rgbtGreen, SumWeights);
RowTween[i].rgbtBlue = WeightPixels(WeightA,
RowA[i].rgbtBlue , WeightB, RowB[i].rgbtBlue , SumWeights);
}//for
}//for
}//if
return result;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::tmr1Timer(TObject *Sender)
{
static iAlpha = 0;
Fade(iAlpha);
if(iAlpha >= 90)
{
tmr1->Enabled = false;
iAlpha = 0;
}
else
{
iAlpha += 10;
}
}
//--------------------------------------------------------------------------- |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|