home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
pascal
/
spx10.zip
/
SPX_UTIL.ZIP
/
CEL2VSP.POC
next >
Wrap
Text File
|
1993-05-06
|
2KB
|
100 lines
/*
* CEL2VSP.poc - This saves the cel to a VSP format.
*
* By Scott Ramsay
*
* For use with Animator Pro
*
*/
#include "errcodes.h"
ErrCode writeVSP(FILE *f,Screen *cel)
{
int width,height,celcnt,i,j;
short w,h;
char *pixbuf = NULL;
ErrCode err;
celcnt = CelFrameCount();
GetScreenSize(cel,&width,&height);
w = width; h = height;
if ((pixbuf=malloc(width))==NULL)
{
err = Err_no_memory;
goto OUT;
}
CelSetFrame(0);
for (j=0;j<celcnt; j++)
{
if ((fwrite(&w,sizeof(w),1,f) != 1) || (fwrite(&h,sizeof(h),1,f) != 1))
{
err = Err_no_space;
goto OUT;
}
for (i=0; i<height; ++i)
{
GetBlock(cel,pixbuf,0,i,width,1);
if (fwrite(pixbuf,1,width,f) != width)
{
err = Err_no_space;
goto OUT;
}
}
CelNextFrame();
}
err = fflush(f);
OUT:
if (pixbuf != NULL)
free(pixbuf);
return(err);
}
ErrCode SaveVSP(char *name)
{
Screen *cel;
FILE *f;
Errcode err;
int width,height;
if (DosExists(name))
{
char *pick[] = {"Yes","No"};
if (Qchoice(pick,2,"Overwrite old \n%s?",name)!=1)
return(Err_abort);
}
cel = GetCelScreen();
GetScreenSize(cel,&width,&height);
if ((width>100) || (height>100))
{
err = Err_no_space;
goto OUT;
}
if ((f=fopen(name,"wb")) == NULL)
{
Qtext("Can't create vsp file %s", name);
return(Err_reported);
}
printf("Saving %d x %d vsp file", width, height);
err = writeVSP(f,cel);
OUT:
fclose(f);
return(Qerror(err,"Trouble saving vsp file: %s", name));
}
main()
{
static char cel_name[80];
GlobalVarGet("CEL2VSP_PATH",cel_name);
if (!CelExists())
Qtext("No cel to save!");
else
if (Qfile(".VSP","Save",cel_name,cel_name,TRUE,"Save cel in .VSP format"))
SaveVSP(cel_name);
GlobalVarSet("CEL2VSP_PATH",cel_name);
}