bool C4Video::RecordFrame() { // No buffer if (!Buffer) return false; // Lock source int iPitch,iWidth,iHeight; if (!Surface->Lock()) { Log("Video: lock surface failure"); Stop(); return false; } iPitch = Surface->PrimarySurfaceLockPitch; BYTE *bypBits = Surface->PrimarySurfaceLockBits; iWidth = Surface->Wdt; iHeight = Surface->Hgt; // Adjust source position if (!AdjustPosition()) { Log("Video: player/viewport failure"); Stop(); return false; } // Blit screen to buffer StdBlit((uint8_t*)bypBits,iPitch,-iHeight, X,Y,Width,Height, (uint8_t*)Buffer+InfoSize, DWordAligned(Width) * (Config.Graphics.BitDepth/8),Height, 0,0,Width,Height, Config.Graphics.BitDepth/8); // Unlock source Surface->Unlock(); // Write frame to file if (!AVIPutFrame(pAviStream, AviFrame, Buffer,InfoSize, Buffer+InfoSize,BufferSize-InfoSize)) { Log("AVIPutFrame failure"); Stop(); return false; } // Advance frame AviFrame++; // Show flash ShowFlash=1; // Success return true; }
BOOL CStdBitmap::Enlarge(int iWdt, int iHgt) { if (!Bits) return FALSE; iWdt = Max(iWdt, (int)Info.biWidth); iHgt = Max(iHgt, (int)Abs(Info.biHeight)); if (!((iWdt > Info.biWidth) || (iHgt > Abs(Info.biHeight)))) return FALSE; int nPitch = DWordAligned(iWdt * Info.biBitCount / 8); int nSize = nPitch * iHgt; BYTE *nBits; if (!(nBits = new BYTE[nSize])) return FALSE; ZeroMem(nBits, nSize); iHgt *= Sign(Info.biHeight); StdBlit((uint8_t *)Bits, Info.Pitch(), Info.biHeight, 0, 0, Info.biWidth, Info.biHeight, (uint8_t *)nBits, nPitch, iHgt, 0, 0, Info.biWidth, Info.biHeight, Info.biBitCount / 8); Info.biWidth = iWdt; Info.biHeight = iHgt; Info.biSizeImage = nSize; delete[] Bits; Bits = nBits; return TRUE; }