Category : C Source Code
Archive   : C_ROTATE.ZIP
Filename : EXAMPLE1.C

 
Output of file : EXAMPLE1.C contained in archive : C_ROTATE.ZIP
/* File IMG saved to disk
Graphics programming in Turbo C++ p245
*/
#ifdef __TINY__
#error Graphics demos will not run in the tiny model.
#endif

#include
#include
#include
#include
#include

#include "gprint.i"

int GraphDriver;
int GraphMode;
double AspectRatio;
int xasp, yasp;
int MaxColors;
int ErrorCode = 0;
void *Flash, *Flash2;

void Pause()
{
while( kbhit() ) getch();
getch();
}

void Initialize()
{
GraphDriver = DETECT;
initgraph( &GraphDriver, &GraphMode, "C:\\APP\\TC\\BGI");
ErrorCode = graphresult();
if( ErrorCode != grOk)
{
printf(" Graphics System Error: %s\n",
grapherrormsg( ErrorCode ) );
exit( 1 );
}
MaxColors = getmaxcolor() + 1;
getaspectratio( &xasp, &yasp );
AspectRatio = (double) xasp / (double) yasp;
}

void *SaveImage(int left, int top, int right, int bottom, unsigned *size)
{
void *image;
*size = imagesize(left, top, right, bottom);
image = malloc( *size );
getimage(left, top, right, bottom, image);
putimage(left, top, image, XOR_PUT);
return( image );
}

void FileImage( void *image, unsigned size, char *filename )
{
FILE *fl = fopen( filename, "w" );
fwrite( image, size, 1, fl);
fflush( fl );
fclose( fl );
}

void *ReadImage( char *filename )
{
unsigned xsize, ysize, size;
FILE *fl = fopen( filename, "r" );
void *tempimage;

xsize = fgetc( fl ) | ( fgetc( fl ) << 8 );
ysize = fgetc( fl ) | ( fgetc( fl ) << 8 );
size = imagesize( 0, 0, xsize, ysize );
gprintxy( 10, 10, " xsize = %d, ysize = %d, imagesize = %d ",
xsize, ysize, size );
tempimage = malloc( size );
rewind( fl );
fread( tempimage, size, 1, fl );
fclose( fl );
return( tempimage );
}

void CreateImage()
{
unsigned Sz = 0;
int MaxColor = getmaxcolor();
int pflash[] = { 100,40, 110,60, 100,70, 120,65, 140,80, 130,60,
140,50, 120,55, 100,40 };
randomize();
setcolor( random( MaxColor ) + 1);
setfillstyle( random(11) + 1, random(MaxColor) + 1);
fillpoly( sizeof(pflash) / (2 * sizeof(int)), pflash );
Flash = SaveImage( 100, 40, 140, 80, &Sz );
FileImage( Flash, Sz, "Flash.Img" );
Flash2 = ReadImage( "Flash.Img" );
putimage( 200, 200, Flash2, COPY_PUT );
}

main()
{
Initialize();
CreateImage();
Pause();
free( Flash );
free( Flash2 );
closegraph();
}



  3 Responses to “Category : C Source Code
Archive   : C_ROTATE.ZIP
Filename : EXAMPLE1.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/