How to draw dynamic bitmap buffer to texture's buffer in directx9?

Job ID: 32496965

Budget: $15 – $25 USD

I have a bitmap buffer ( with width,height and size) which was dynamic updated by a thread from a video file, I wrote this bitmap buffer to my texture buffer(IDirect3DTexture9*m_pTexture).

D3DLOCKED_RECT d3dlr;
if(FAILED(m_pTexture->LockRect(0, &d3dlr, 0, 0))) {
printf("lock failed");
}

BYTE *pTexturePtr = (BYTE*)d3dlr.pBits;
LONG lTexturePitch = d3dlr.Pitch;

pTexturePtr += (lTexturePitch * (m_nHeight-1));

for(int y = 0; y < m_nHeight; y ++) {

memcpy(pTexturePtr, lpBits, m_nWidth * 4);
pTexturePtr -= lTexturePitch;
lpBits += m_nWidth * 4;
}

if(FAILED(m_pTexture->UnlockRect(0))) {
printf("unlock failed");
}

//Create a scale vector
D3DXVECTOR2 scale(scaling, scaling);

//Create a translate vector
D3DXVECTOR2 trans(x, y);

//Set center by dividing width and height by two
D3DXVECTOR2 center((float)(width * scaling) / 2, (float)(height * scaling)/2);

//Create 2D transformation matrix
D3DXMATRIX mat, old;
D3DXMatrixTransformation2D(&mat, NULL, 0, &scale, &center, rotation, &trans);

//Tell sprite object to use the transform

m_pSprite->SetTransform( &mat );

//Calculate frame location in source image
int fx = 0;
int fy = 0;
RECT srcRect = {fx, fy, fx + width, fy + height};

m_pSprite->Begin(0); //D3DXSPRITE_ALPHABLEND
//draw the sprite frame
m_pSprite->Draw(m_pTexture, &srcRect, NULL, NULL, color);//D3DCOLOR_ARGB(0xff,0xff,0xff,0xff)

m_pSprite->Flush();
m_pSprite->End();

If I remove part of "m_pSprite->SetTransform( &mat );", it works well. but if i put this code in , my texture is transparent. Can you explain me why and show me how to resolve this problem.