PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

General CGapiSurface Question - Plea for Advice :)

My application loads a jpeg image from a file or resource... I can obtain a handle to the bitmap (HBITMAP) that results from the jpeg load.

I need to create a CGapiSurface from the HBITMAP or have some way to blit the image onto an existig CGapiSurface.. either way will suffice. Basically I want to create a surface from a JPEG.

Does anyone see a way that is possible within the GapiDraw framework? I plan on using the CreateSurface() implementation that takes a bitmap file in memory to accomplish this. I assume the bitmap file in memory refers to a bitmap handle (?? is this true Johan). Does this make sense or am I heading in the wrong direction ??

Any help is appreciated.
Thanks.
Jeff
Hi Jeff,

The current solution actually refers to an 1:1 bitmap file (a BMP file read into memory). We commonly use it for simple image transfers in the OpenTrek platform.

The easiest way? Just use GetDC() on the CGapiSurface and BitBlt (using DCs) your HBITMAP to the surface. I think this is the standard way of doing it in DirectDraw on stationary computers. If you search the web you would probably find several examples of this as well.

I would suggest the following steps:
(1) Load JPEG
(2) Create surface, matching the size of the JPEG
(3) Get Surface DC (GetDC)
(4) BitBlt (using DC) your bitmap to the surface.
(5) Release the Surface DC (ReleaseDC)

Best of luck,
Johan
Thanks much for the info :) I should have realized that I could get the DC of the CGapiSurface and just do a BitBlt to it.

-Jeff