Windows Mobile 5 newbie, C++, Win32

I want to get a pointer to a memory buffer containing raw pixel data from
an image loaded from a file. I've got code that loads the file into memory,
and code that displays that image. But I want to access the memory that has
the image data directly, and I want to do it my own buffer ins of the display
memory.

I can access the framebuffer directly: I do that by creating a surface with
IDirectDraw::CreateSurface, which creates one for the device's display.

Is there a way to get a surface for an in-memory device context?
GetSurfaceFromDC would seem to do this, except that its documentation says
that it "will succeed only for device context handles that identify surfaces
already associated with the DirectDraw object." I don't know how to set up a
device context to do that.

Re: How to associate a directdraw surface with a DC by Don

Don
Fri Nov 24 21:27:19 CST 2006

If you create a DIB section, and select that into an offscreen DC then
you'll have an HBITMAP to use for blitting as well a pointer to the raw
bitmap pixel data. Or, you could just create a DDraw surface that is the
same size as your offscreen DC then retrieve the device context of the DDraw
surface using IDirectDrawSurface::GetDC and then use that as the destination
of a GDI BitBlt call. Once the bits are in the DDraw surface you can lock
it and get direct access to the pixel data.


"R Cook" <R Cook@discussions.microsoft.com> wrote in message
news:74B9B6E9-62EB-4CB3-B50B-036CE7E3ADD7@microsoft.com...
> Windows Mobile 5 newbie, C++, Win32
>
> I want to get a pointer to a memory buffer containing raw pixel data from
> an image loaded from a file. I've got code that loads the file into
> memory,
> and code that displays that image. But I want to access the memory that
> has
> the image data directly, and I want to do it my own buffer ins of the
> display
> memory.
>
> I can access the framebuffer directly: I do that by creating a surface
> with
> IDirectDraw::CreateSurface, which creates one for the device's display.
>
> Is there a way to get a surface for an in-memory device context?
> GetSurfaceFromDC would seem to do this, except that its documentation says
> that it "will succeed only for device context handles that identify
> surfaces
> already associated with the DirectDraw object." I don't know how to set
> up a
> device context to do that.