I loaded an image from file and want to write it to AVI file:
Gdiplus::Bitmap frame(L"test.png", FALSE);
Gdiplus::BitmapData bmp_data = {};
Gdiplus::Rect rect(0, 0, frame.GetWidth(), frame.GetHeight());
frame.LockBits(&rect, Gdiplus::ImageLockModeRead, frame.GetPixelFormat(),
&bmp_data);
AVIStreamWrite(avi_stream, i, 1, bmp_data.Scan0,
std::abs(bmp_data.Stride) * bmp_data.Height, AVIIF_KEYFRAME, NULL, NULL);
frame.UnlockBits(&bmp_data);
Resulting avi-file is rotated by 180 degrees. What's wrong?
Also I noticed that original image was bottom-up (Bitmap::LockBits()
returned negative BitmapData::Stride
). I saved it to disk by Bitmap::Save()
. After loading the image is top-down.
精彩评论