#ifdef __WIN32__
#include <windows.h>
#endif

#include "PowerPak/powerpak.h"
#include "PowerPak/powerdraw.h"

/* This fix was provided by Jesper Juul */
#ifdef __WIN32__
int WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int cmdShow)
{
main();
}
#endif

main(int argc, char *argv[])
{
   float i;
   int w, h;
   PD_Surface *surface, *surface2;

   /* Initialize the library */
   PP_Init();
   PD_Init();

   /* Initialize 640x480x16bpp graphics mode */
   PD_SetGFXMode(640, 480, 16, PD_DEFAULT);

   /* Create the surface to draw on  */
   surface = PD_LoadImage("ex4.pcx");

   /* Copy the surface to screen */
   PD_Blit(surface, DoubleBuffer, 0, 0, 192, 112, 256, 256);

   /* Show the doublebuffer */
   PD_ShowDoubleBuffer();

   /* wait 1 second so you can see it */
   PP_Wait(1000);

   /* Create a stretched version */
   for (i = 1.0; i < 3.0; i += .075){
      w = surface->w*i;
      h = 34*i;
      surface2 = PD_ScaleSurfacePart(surface, 0, 111, surface->w, 145, w, h);
      PD_Blit(surface2, DoubleBuffer, 0, 0, 320-(w>>1), 240-(h>>1), w, h);
      PD_ShowDoubleBuffer();
   }

   for (i = 1.0; i < 3.0; i += .075){
      surface2 = PD_ScaleSurfacePartBy(surface, 0, 111, surface->w, 145, -i, -i);
      PD_Blit(surface2, DoubleBuffer, 0, 0, 320-(surface2->w>>1), 240-(surface2->h>>1), surface2->w, surface2->h);
      PD_ShowDoubleBuffer();
   }

   PP_Wait(1000);

   /* Cleanup */
   PD_Quit();
   PP_Quit();
}
