我正在尝试为给定的jpg图像创建一个avi文件。我正在阅读jpg使用库并为它准备hbitmap。最后我添加它来创建avi文件。但我的最终avi文件包含倒置图像。我在bitmapheader中保持高位。我的hbitmap仍然是倒置的。你能帮忙解决错误原因吗
这里我给出了我实施的代码
void makeVideo()
{
GoldImage Test ;
for(int i=0;i<10;i++)
{
Test.SetImage(m_MyImage[i])
HBITMAP hBitmap;
Test.GetBitMap(0,0,hBitmap);
if(i==0)
{
avi = CreateAvi("test.avi",1000,NULL);
AVICOMPRESSOPTIONS opts; ZeroMemory(&opts,sizeof(opts));
SetAviVideoCompression(avi,hBitmap,&opts,true,NULL);
}
AddAviFrame(avi,hBitmap);
}
CloseAvi();
}
void GoldImage::GetBitMap(HBITMAP &hBitmap)
{
BITMAPINFOHEADER bmi;
bmi.biSize = sizeof(BITMAPINFOHEADER);
bmi.biWidth = Width
**bmi.biHeight = (-1)*Height;**
bmi.biPlanes = 1;
bmi.biBitCount = 32;
**bmi.biCompression = BI_RGB;**
bmi.biSizeImage = 0;
bmi.biXPelsPerMeter = 0;
bmi.biYPelsPerMeter = 0;
bmi.biClrUsed = 0;
bmi.biClrImportant = 0;
RGBQUAD *prgbaDIB = 0;
hBitmap = CreateDIBSection ( NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS, (void**)&prgbaDIB, NULL, 0 );
const unsigned int columns = m_Image.columns();
const unsigned int rows = m_Image.rows();
RGBQUAD *pDestPixel = prgbaDIB;
for( unsigned int row = 0 ; row < rows ; row++ )
{
const PixelPacket *pPixels = m_Image.getConstPixels(0,row,columns,1);
for( unsigned long nPixelCount = columns; nPixelCount ; nPixelCount-- )
{
pDestPixel->rgbRed = ScaleQuantumToChar(pPixels->red);
pDestPixel->rgbGreen = ScaleQuantumToChar(pPixels->green);
pDestPixel->rgbBlue = ScaleQuantumToChar(pPixels->blue);
pDestPixel->rgbReserved = 0;
++pDestPixel;
++pPixels;
}
}
}
先谢谢
答案 0 :(得分:2)
位图的扫描线上下存储。当你直接写出像素时,你必须补偿这一点。
答案 1 :(得分:0)