开发者

GDI+ Bitmap LockBits returns rotated image?

开发者_JAVA百科

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜