The mouse move make graphic data move

The mouse move make graphic data move

Post by davi » Sat, 23 Feb 2002 11:44:20



Dear Sir :
My code as following,  It can't determine a correct direction when I move
mouse from right to left.
It just only move to up or down.
By the way, Its speed is so slowly to move, Why?

void __fastcall TFormImageEdit::ImageEditGridMouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
    NewImgMovePosX=X;
    NewImgMovePosY=Y;
if (ImgMove)
  {
  if (OldImgMovePosY>NewImgMovePosY )
       ImageMoveDirection(WM_MoveUp ) ;    //this function is writed myself
   if (OldImgMovePosY<NewImgMovePosY )
      ImageMoveDirection(WM_MoveDown);
   if (OldImgMovePosX<NewImgMovePosX )
      ImageMoveDirection(WM_MoveLeft ) ;
   if (OldImgMovePosX>NewImgMovePosX )
      ImageMoveDirection(WM_MoveRight ) ;
  }

Quote:}

David
 
 
 

The mouse move make graphic data move

Post by Adam Versteege » Sat, 23 Feb 2002 12:39:32


Hello David,
While its hard to be sure as I can't see your ImageMoveDirection function, I
have spotted one problem.

Quote:>   if (OldImgMovePosY>NewImgMovePosY )
>        ImageMoveDirection(WM_MoveUp ) ;    //this function is writed
myself
>    if (OldImgMovePosY<NewImgMovePosY )
>       ImageMoveDirection(WM_MoveDown);
>    if (OldImgMovePosX<NewImgMovePosX )

If you are following a normal coordinate system, then if your old X ordinate
is less than the new one, then the image is moving right, not left.

Quote:>       ImageMoveDirection(WM_MoveLeft ) ;
>    if (OldImgMovePosX>NewImgMovePosX )

Same as above, you ahve it round the wrong way.

Quote:>       ImageMoveDirection(WM_MoveRight ) ;

As for the speed of moving, well I would need to be able to see your
ImageMoveDirection function to be able to help there.

Vesty.

 
 
 

The mouse move make graphic data move

Post by davi » Sat, 23 Feb 2002 13:20:18



> If you are following a normal coordinate system, then if your old X
ordinate
> is less than the new one, then the image is moving right, not left.

Thanks , I see;

Quote:> While its hard to be sure as I can't see your ImageMoveDirection function,
I
> have spotted one problem.

 > As for the speed of moving, well I would need to be able to see your

Quote:> ImageMoveDirection function to be able to help there.

my code as following:

int cnt=1;
  switch(MoveDirection)
  {
  case WM_MoveUp:
     for (int i=0 ; i < ImageEditGrid->Width ; i++)
       {
          ImgRowBuf[0][i*3]=ImageBuffer[0][i*3];
          ImgRowBuf[0][i*3+1]=ImageBuffer[0][i*3+1];
          ImgRowBuf[0][i*3+2]=ImageBuffer[0][i*3+2];
       }
     for ( int col =0 ,j ; col <  ImageEditGrid->Width  ; col++)   //i =col
,j= row
        for ( int row  =0 ;row < ImageEditGrid->Height  ; row++)
//scanline -->row
              {
                      j= (row+cnt)  >= ImageEditGrid->Height
                          ? (row+cnt)  - ImageEditGrid->Height
                          : (row+cnt) ;    //if > width then wrap
                      ImageBuffer[row][col*3] = ImageBuffer[j][col*3];
//Lsb->Msb
                      ImageBuffer[row][col*3+1] =ImageBuffer[j][col*3+1];
                      ImageBuffer[row][col*3+2] =ImageBuffer[j][col*3+2];
               }
     for (int i=0 ; i < ImageEditGrid->Width ; i++)
       {
//          ImageBuffer[ImageEditGrid->Height-1][i*3]=ImgColBuf[0][i*3];
//add the three row will make some error, so I mark it
//          ImageBuffer[ImageEditGrid->Height-1][i*3+1]=ImgColBuf[0][i*3+1];
//          ImageBuffer[ImageEditGrid->Height-1][i*3+2]=ImgColBuf[0][i*3+2];
       }
       break;
  case WM_MoveDown:
     for (int i=0 ; i < ImageEditGrid->Width ; i++)
       {
          ImgRowBuf[0][i*3]=ImageBuffer[ImageEditGrid->Height-1][i*3];
          ImgRowBuf[0][i*3+1]=ImageBuffer[ImageEditGrid->Height-1][i*3+1];
          ImgRowBuf[0][i*3+2]=ImageBuffer[ImageEditGrid->Height-1][i*3+2];
       }
     for ( int col=  ImageEditGrid->Width-1,j ; col >=0 ; col--)   //i =col
,j= row
        for ( int row= ImageEditGrid->Height-1 ;row  >=0 ; row--)
//scanline -->row, ??|Cao???
              {
                      j= (row+cnt)  >= ImageEditGrid->Height
                          ? (row+cnt)  - ImageEditGrid->Height
                          : (row+cnt) ;    //if > width then wrap
                      ImageBuffer[j][col*3] = ImageBuffer[row][col*3] ;
//Lsb->Msb
                      ImageBuffer[j][col*3+1]  =ImageBuffer[row][col*3+1];
                      ImageBuffer[j][col*3+2]  =ImageBuffer[row][col*3+2];
               }
     for (int i=0 ; i < ImageEditGrid->Width ; i++)
       {
          ImageBuffer[0][i*3]=ImgColBuf[0][i*3];
          ImageBuffer[0][i*3+1]=ImgColBuf[0][i*3+1];
          ImageBuffer[0][i*3+2]=ImgColBuf[0][i*3+2];
       }
       break;

Quote:}

then show it as following:
    for ( int j =0 ; j<  ImageEditGrid->Height; j++)    //scanline -->row,
??|Cao???
      for ( int i =0 ; i<  ImageEditGrid->Width ; i++)   //i =col ,j= row
           {
                   int CRed =ImageBuffer[j][i*3];
                   int CGreen =ImageBuffer[j][i*3+1];
                   int CBlue =ImageBuffer[j][i*3+2];
                   SetPixel(ImageEditGrid->Canvas->Handle,i,j,(COLORREF)
RGB(CRed,CGreen,CBlue)) ;
           }

has any other way to make it the speedest.
and how can i  reduce its rate that graphic data

Thanks~

David

 
 
 

1. Mouse move and mouse enter Events

Hi!

I'm using a SoQtPlaneViewer in my Qt project. To catch mouse events I
use a callback function that is attached to the render area of the
viewer.
But the callback function registers only events when the mouse button
is pressed over the viewer. I also need mouse move and mouse enter
events.
Can anybody tell me how I can do this with the callback function or
are there other ways to realize this functionality?

Bye Marcus

2. WANTED: Fontographer 4.x

3. Light blockers moving when the camera moves

4. Find Edges Tool

5. Moving camera with moving objects in Inventor

6. DelphiX DXDraw in TScrollBox Clipping Problem

7. PC fast screen region copy/restore routines in Assembler ????

8. select() changes speed if mouse moves

9. Moving the cursor with Keys? (not mouse)

10. moving layers with mouse v. keyboard

11. Looking for a USB mouse user (about smooth move)