void DrawMovie(int x,int y,ITexture* texture) { const u32 pitch = texture->getPitch(); u8* pTex = (u8*)texture->lock()+(y*pitch); CImage *image; u8 bpp; // Create image of correct depth from movie frame if (texture->getColorFormat()==ECF_A1R5G5B5) { image = new avm::CImage(pSurface, 15); bpp=2; } else { image = new avm::CImage(pSurface, 32); bpp=4; } uint8_t* pPixel=image->At(0,0); // Check for area to be drawn. Avoid access out of bound. u32 minWidth=(pitch<image->Bpl())?pitch:image->Bpl(); u32 minHeight=(image->Height()<texture->getSize().Height)?image->Height():texture->getSize().Height; // copy movie frame to texture for(int h=0; h<minHeight; ++h) { memcpy(pTex+x*bpp,pPixel,minWidth); // jump to next scanline pTex+=pitch; pPixel+=image->Bpl(); } delete image; texture->unlock(); }