Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image transition

Status
Not open for further replies.

ashstampede

Programmer
Aug 30, 2004
104
0
0
GB
Hi I am trying to code a image transition using copyRECT with no success.

currently what is happening is a small junk of the old/current image is copied on to the new image and then just stays as the slide show continues.

here is so code i have attempting to wipe the image in from the left.

Code:
//Wipe Image
 void Wipe(TImage *imgDisplay,
           Graphics::TBitmap *bmpNew,//copyBackBuffer
           Graphics::TBitmap *bmpOld,//BackBuffer
           int Direction=FROMLEFT,
           int Resolution=20,
           int FrameDelay=0);

//set the next image to wipe into the form over the
//top of the other picture
void C_Transition::Wipe(TImage *img,
           Graphics::TBitmap *bmpNew,
           Graphics::TBitmap *bmpOld,
           int Direction,
           int Resolution,
           int FrameDelay)
{
  //timing
    int frame = 0;
    //FrameDelay = bmpNew->Width / 100; //1/100th of the width

    //SET up variables for slide transition
    //integers for the new picture in COPYBackBuffer
    int newStartX = 0;
    int newStartY = 0;
    int newEndX = 0;
    int newEndY = 0;
    int newCurrentX = 0;
    int newCurrentY = 0;

    //integers for the old picture in the OLD BackBuffer
    int oldStartX = 0;
    int oldStartY = 0;
    int oldEndX = 0;
    int oldEndY = 0;
    int oldCurrentX = 0;
    int oldCurrentY = 0;

     //what side is the image loading from
    if(Direction == FROMLEFT)
    {
      newStartX = -bmpNew->Width; //negative x
      newEndX = newStartX + bmpNew->Width;
      newCurrentX = newEndX; //current X moves with the resolution
                             //increments for the copy rect to get from start
                             //to current
      oldEndX = bmpOld->Width;
      oldStartX = oldEndX - bmpOld->Width;
      oldCurrentX = oldStartX;
      //moving from the left side of the screen
      //start the new image the width of the image box
      //increment newStartX to coordinates 0,0
      //loop counter
      int i = 0;
      while(i > newStartX)
      {
        //FRAME DELAY LOOP
        while(frame != FrameDelay)
        {
          frame++;
        }
        frame = 0;

        //increment
        newCurrentX -= Resolution;
        oldCurrentX += Resolution;
                                //x,y,right,bottom
                                //start at the end of the rect and move <-----
        img->Canvas->CopyRect(Rect(newCurrentX,newCurrentY,newEndX,newEndY),img->Canvas,
                              Rect(oldStartX,oldStartY,oldCurrentX,oldCurrentY));
                                       //start at 0,0 and overright ---->
         i-= Resolution;
        //<-----decrement
      }
    }//END DIRECTION LEFT
}

The backBuffer is the current picture and the copy is the new picture. they get the files from my main program.
img is the picture box from my form.

Help is really appreciated as i have little more than 3hrs to finish this. :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top