PDA

View Full Version : JPG, PNG, GIF format supported in non-GameAPI programs.


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>

kornalius
09-14-2007, 03:12 PM
There will be a new demo ImgLoader.frm with ppl.jpg files included in the Demos folder of PPL 1.30 which will be released later today.

Jim Burton
09-14-2007, 03:15 PM
Awesome!

I did get some image loading working with SHLoadImageFile, but this will be much nicer because it will work with all platforms!