Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GDI+ LockBits flips data

140 views
Skip to first unread message

Peter Krnjevic

unread,
Nov 16, 2001, 4:56:03 PM11/16/01
to
I know I saw something about this but can't find it again. Anybody know why
Bitmap::LockBits is flipping my bitmap upside down? And is there a way to
avoid this?

Peter


Greg Binkerd [MS]

unread,
Nov 16, 2001, 6:52:22 PM11/16/01
to
Peter,

How are you setting up the "Stride" in your BitmapData Class when defining
your bitmap data?

If the pixel data is stored bottom-up, the Stride data member is negative.
If the pixel data is stored top-down, the Stride data member is positive.

-Greg
Microsoft Developer Support

This posting is provided “AS IS” with no warranties, and confers no rights.

Peter Krnjevic

unread,
Nov 16, 2001, 7:30:59 PM11/16/01
to
Greg,

I tried that but it causes an exception: Access Violation in GDIPLUS.DLL!
GdipCreateBitmapFromScan0 + 9497 bytes.
I'm preallocating the buffer and everything works fine (only upside down)
when Stride is positive.
Any suggestions?

Thanks,
Peter

"Greg Binkerd [MS]" <GregB...@Microsoft.com> wrote in message
news:ZmdS6kv...@cppssbbsa01.microsoft.com...

Greg Binkerd [MS]

unread,
Nov 19, 2001, 3:25:42 PM11/19/01
to
scan0 must point to the start of the first scanline of the bitmap (not the
start of the buffer that contains the bitmap bits). It's only for
top-down bitmaps that the first scanline matches the start of the bitmap
bits buffer. It could be that your stride is negative but you are
advancing through the bits as though it were positive.

I don't know if this is the problem in your case. Let me know.

Thanks,

Peter Krnjevic

unread,
Nov 19, 2001, 4:55:57 PM11/19/01
to
Scan0 points to the start of my bitmap's bits. I'm so used to Windows
top-down bitmaps that anything else almost seems to complicated! <g>

Thanks,
Peter

"Greg Binkerd [MS]" <GregB...@Microsoft.com> wrote in message

news:Xvw6OfT...@cppssbbsa01.microsoft.com...

0 new messages