Re: [3/4] windowscodecs: Implement CreateBitmapFromMemory.
Vincent Povirk <madewokherd(a)gmail.com> wrote:
+ hr = IWICBitmap_Lock(bitmap, NULL, WICBitmapLockWrite, &lock); + if (SUCCEEDED(hr)) + { + UINT buffersize; + BYTE *buffer; + + hr = IWICBitmapLock_GetDataPointer(lock, &buffersize, &buffer); + + memcpy(buffer, pbBuffer, uiHeight * cbStride); + + IWICBitmapLock_Release(lock); + }
It's better to actually check return value of IWICBitmapLock_GetDataPointer before memecpy(), or if that's not supposed to fail drop 'hr' assignment. My approach to pass buffer directly to BitmapImpl_Create looks much simpler than fiddling with IWICBitmap_Lock IMHO. -- Dmitry.
On Wed, Jan 2, 2013 at 11:42 PM, Dmitry Timoshkov <dmitry(a)baikal.ru> wrote:
It's better to actually check return value of IWICBitmapLock_GetDataPointer before memecpy(), or if that's not supposed to fail drop 'hr' assignment.
Whoops, good catch. (I don't think it can fail, but I didn't mean to make that assumption.) I guess I prefer to keep interfaces as simple as possible even if it means writing more code? I'd consider writing a helper function, but none of the other methods would use it.
Vincent Povirk <madewokherd(a)gmail.com> wrote:
I guess I prefer to keep interfaces as simple as possible even if it means writing more code? I'd consider writing a helper function, but none of the other methods would use it.
Is there any hurry with CreateBitmapFromMemory implementation, or you somehow prefer your own one? I'm asking because I was planning to send my implementation (fixed to create a copy of the passed in buffer) after new year vacations, but it looks like you need it right now. -- Dmitry.
participants (2)
-
Dmitry Timoshkov -
Vincent Povirk