BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Visual transistions

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
Ed Critchlow
Guest





PostPosted: Wed Oct 29, 2003 8:05 pm    Post subject: Visual transistions Reply with quote



I would like to be able to slowly dissolve from one image to another, not
simply display a new image. I know how to do this in VC++ but in my
application I have a form with text labels and images which are just filled
in and displayed. I can't find where they are actually drawn. Does this all
happen in the bowels of VCL? Any ideas of how to go about this?

Ed


Back to top
Francisco Sanchez
Guest





PostPosted: Thu Oct 30, 2003 3:15 pm    Post subject: Re: Visual transistions Reply with quote



Hi,

In article <3fa01d8e (AT) newsgroups (DOT) borland.com>, [email]edc (AT) record-machine (DOT) com[/email]
says...
Quote:
I would like to be able to slowly dissolve from one image to another, not
simply display a new image. I know how to do this in VC++ but in my
application I have a form with text labels and images which are just filled
in and displayed. I can't find where they are actually drawn. Does this all
happen in the bowels of VCL? Any ideas of how to go about this?

Take a look at Billenium Effects (shareware). You can download an exe
demo and trial versions at http://www.billeniumsoft.com

Regards,
Francisco Sanchez
[email]fsanchez (AT) billeniumsoft (DOT) com[/email]
http://www.billeniumsoft.com

Back to top
Damon Chandler (TeamB)
Guest





PostPosted: Fri Oct 31, 2003 7:28 am    Post subject: Re: Visual transistions Reply with quote



Ed,
Quote:
I would like to be able to slowly dissolve from one image to another,
not simply display a new image. I know how to do this in VC++ but in my
application I have a form with text labels and images which are just
filled in and displayed.

If you're using a TImage component, then you'll need to work with its
contained TBitmap object. Here's an example that demonstrates how to
gradually fade from a bitmap (Bitmap1) displayed in a TImage (Image1) to
another bitmap (Bitmap2) that's loaded from a file...

#include <cassert>
#include <memory>
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
// grab a pointer to the TBitmap object displayed in Image1
Graphics::TBitmap* Bitmap1 = Image1->Picture->Bitmap;
// store Bitmap1's dimensions
SIZE const SBitmap = {Bitmap1->Width, Bitmap1->Height};

// load the next image into a new TBitmap object
std::auto_ptr<Graphics::TBitmap> Bitmap2(new Graphics::TBitmap());
Bitmap2->LoadFromFile("c:/bitmap2.bmp");
assert(Bitmap2->Width == SBitmap.cx);
assert(Bitmap2->Height == SBitmap.cy);

// assuming 24-bit images
assert(Bitmap1->PixelFormat == pf24bit);
assert(Bitmap2->PixelFormat == pf24bit);

// incrementally blend the pixel values of the two
// images, storing the results in Bitmap1...
for (int step = 1; step < 10; ++step)
{
float const alpha2 = step / 10.0f;
float const alpha1 = 1.0f - alpha2;
for (int y = 0; y < SBitmap.cy; ++y)
{
// grab a pointer to the y-th row of each image
RGBTRIPLE* pRow1 =
static_castScanLine[y]);
RGBTRIPLE const* pRow2 =
static_cast<RGBTRIPLE*>(Bitmap2->ScanLine[y]);
for (int x = 0; x < SBitmap.cx; ++x)
{
pRow1[x].rgbtRed =
alpha1 * pRow1[x].rgbtRed +
alpha2 * pRow2[x].rgbtRed;
pRow1[x].rgbtGreen =
alpha1 * pRow1[x].rgbtGreen +
alpha2 * pRow2[x].rgbtGreen;
pRow1[x].rgbtBlue =
alpha1 * pRow1[x].rgbtBlue +
alpha2 * pRow2[x].rgbtBlue;
}
}

// instruct Image1 to redraw Bitmap1
Image1->Refresh();
Sleep(50);
}
}

You may want to use a TTimer component to avoid the blocking Sleep() call.
Also, if you notice flickering, set the TImage's Stretch property to true.

Good luck,
Damon (TeamB)

Back to top
Damon Chandler (TeamB)
Guest





PostPosted: Fri Oct 31, 2003 7:42 am    Post subject: Re: Visual transistions Reply with quote


Also, you might want to have a look at the AlphaBlend() function if you
don't need to deploy on Windows 95 or NT4...

http://tinyurl.com/t478

Damon
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.