kornalius
09-14-2007, 02:57 PM
You can use all the power of the LoadSurface(), SaveSurface(), g_GetDC and g_ReleaseDC functions without the need to initialize the GameAPI in your programs.
If you design a Windows program using the PIDE Visual Form Builder, you can easily add support for JPG, PNG and GIF file formats to the BITMAP control. In your form OnCreate code just do the following:
* Global(s$);
* s$ = loadsurface("c:\\ppl\\ppltest\\vista.jpg", 0);
Then in your form OnDestroy code do:
* FreeSurface(s$);
Now to draw the surface to an HDC do the following in your bitmap OnPaint code:
* struct(ps$, PAINTSTRUCT);
* hdc$ = BeginPaint(hWnd$, &ps$);* dc$ = g_getdc(s$); * BitBlt(hdc$, 0, 0, SurfaceWidth(s$), SurfaceHeight(s$), dc$, 0, 0, SRCCOPY);* g_releasedc(s$, dc$);
* EndPaint(hWnd$, &ps$);
* ReleaseDC(hWnd$, hdc$);
That's it, now you have multiple file formats to display in your forms! </p>
If you design a Windows program using the PIDE Visual Form Builder, you can easily add support for JPG, PNG and GIF file formats to the BITMAP control. In your form OnCreate code just do the following:
* Global(s$);
* s$ = loadsurface("c:\\ppl\\ppltest\\vista.jpg", 0);
Then in your form OnDestroy code do:
* FreeSurface(s$);
Now to draw the surface to an HDC do the following in your bitmap OnPaint code:
* struct(ps$, PAINTSTRUCT);
* hdc$ = BeginPaint(hWnd$, &ps$);* dc$ = g_getdc(s$); * BitBlt(hdc$, 0, 0, SurfaceWidth(s$), SurfaceHeight(s$), dc$, 0, 0, SRCCOPY);* g_releasedc(s$, dc$);
* EndPaint(hWnd$, &ps$);
* ReleaseDC(hWnd$, hdc$);
That's it, now you have multiple file formats to display in your forms! </p>