Hello !
Here is some code that tries to test a target width x height for an output AVI with a given compressor.
Unfortunately, it does not work correctly as the call to ICCompressQuery(...) always return true.
#include
#include
#include
#include
#include
struct VideoSize2
{
const char * mLabel;
int mWidth, mHeight;
};
struct VideoSize2 toto[] =
{
{"QVGA", 320, 240},
{"VCD NTSC", 352, 240},
{"VCD PAL", 352, 288},
{"VGA", 640, 480},
{"DVD NTSC", 720, 480},
{"DVD PAL", 720, 576},
{"SVGA", 800, 600},
{"XGA", 1024, 768},
{"WXGA", 1280, 720},
{"SXGA", 1280, 1024},
{"UXGA", 1600, 1200},
{"HD 1080", 1920, 1080},
{"WUXGA", 1920, 1200},
{NULL, 0, 0},
};
//---
void test_func()
{
AVIFileInit();
COMPVARS _pc;
_pc.cbSize = sizeof(COMPVARS);
ICCompressorChoose( NULL, ICMF_CHOOSE_ALLCOMPRESSORS, NULL, NULL, &_pc, "Select Compressor");
for (int i=0; toto[i].mLabel; i++)
{
int nwidth = toto[i].mWidth;
int nheight = toto[i].mHeight;
// intput format
BITMAPINFO bi;
ZeroMemory(&bi, sizeof(bi));
BITMAPINFOHEADER & bih = bi.bmiHeader;
memset(&bih, 0, sizeof(bih));
bih.biSize = sizeof(bih);
bih.biWidth = nwidth;
bih.biHeight = nheight;
bih.biPlanes = 1;
bih.biBitCount = 24;
bih.biCompression=BI_RGB;
bih.biSizeImage = ((bih.biWidth*bih.biBitCount/8+3)&0xFFFFFFFC)*bih.biHeight;
bih.biXPelsPerMeter=10000;
bih.biYPelsPerMeter=10000;
bih.biClrUsed=0;
bih.biClrImportant=0;
// output format
BITMAPINFO bo;
ZeroMemory(&bo, sizeof(bo));
BITMAPINFOHEADER & boh = bo.bmiHeader;
memset(&boh, 0, sizeof(boh));
boh.biSize = sizeof(boh);
boh.biWidth = nwidth;
boh.biHeight = nheight;
boh.biPlanes = 1;
boh.biBitCount = 24;
boh.biCompression = 808802372; // notice here that value 'BI_RLE8' will make ICCompressQuery fail
boh.biSizeImage = ((boh.biWidth*boh.biBitCount/8+3)&0xFFFFFFFC)*boh.biHeight;
boh.biXPelsPerMeter=0;
boh.biYPelsPerMeter=0;
boh.biClrUsed=0;
boh.biClrImportant=0;
LRESULT hr = ICCompressQuery(_pc.hic, &bi, &bo);
bool okFormat = false;
if (hr == ICERR_OK)
okFormat = true;
int toto = 0;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
test_func();
return 0;
}