标签:
//截图 int cropImage(const char* file, int left, int top, int right, int bottom, BYTE* &dstData, DWORD& dstLen) { DWORD dw1 = GetTickCount(); fipImage image; BOOL bSuccess = image.load(file); if ( !bSuccess ) { printf("image.load fail\n"); return -1; } //bSuccess = image.crop(0, 0, 300, 200); bSuccess = image.crop(left, top, right, bottom); if ( !bSuccess ) { printf("image.crop fail\n"); return -1; } // fipImage -> fipMenoryIO fipMemoryIO memIO; bSuccess = image.saveToMemory(FIF_JPEG, memIO, JPEG_DEFAULT); if ( !bSuccess ) { printf("image.saveToMemory fail\n"); return -1; } // fipMemoryIO -> char* BYTE* srcData = NULL;; DWORD size_in_bytes = 0; bSuccess = memIO.acquire(&srcData, &size_in_bytes); if ( !bSuccess ) { printf("memIO.acquire fail\n"); return -1; } DWORD dw2 = GetTickCount() - dw1; printf("%u\n", dw2); dstLen = size_in_bytes; BYTE* data = new BYTE[dstLen]; memcpy(data, srcData, dstLen); dstData = data; // bSuccess = image.save("crop.jpg"); return 0; } //函数使用 BYTE* data = NULL;; DWORD dataLen = 0; cropImage(lpszTestFile, 0, 0, 300, 200, data, dataLen);
标签:
原文地址:http://www.cnblogs.com/jingdian1956/p/4704415.html