Category : Files from Magazines
Archive   : DDJ9407C.ZIP
Filename : RAYTGA.CPP
/*** (C) Copyright A.MANGEN 1994 ***/
/***********************************************************************/
/*** PROJECT : RAY TRACING PROGRAM ***/
/*** PROGRAM NAME: RAYTGA.CPP ***/
/*** VERSION : 1.1 ***/
/***-----------------------------------------------------------------***/
/*** DESCRIPTION : TARGA Graphic File Interface ***/
/***********************************************************************/
#include
#include
#include "raytga.h"
TGAFile::TGAFile(char *FileName,int Width,int Height,int BW)
{ long i,j;
if(FileName==NULL)
fp=NULL;
else
{ fp=fopen(FileName,"wb");
setvbuf(fp,NULL,_IOFBF,32767);
memset(&H,0,sizeof(struct TGAHeader));
switch(BW)
{ case 0:
H.ImageTypeCode=2; // Uncompressed RGB
BytesPerPixel=3;
break;
case 1:
H.ImageTypeCode=1; // Uncompressed ColorMapped
H.ColorMapType=1;
H.ColorMapOrigin=0;
H.ColorMapLength=256;
H.ColorMapEntrySize=24;
BytesPerPixel=1;
break;
}
H.Width=Width; // Image Width
H.Height=Height; // Image Height
H.ImagePixelSize=8*BytesPerPixel;
H.ImageDescriptorByte=0x20; // Flip vertically
fwrite(&H,sizeof(struct TGAHeader),1,fp);
switch(BW)
{ case 1: // Write a greyscale colormap
for(i=0;i<256;i++)
{ j=(i<<16)+(i<<8)+i;
fwrite(&j,3,1,fp);
}
break;
}
}
}
TGAFile::~TGAFile()
{ if(fp!=NULL) fclose(fp); fp=NULL;
}
void TGAFile::WritePixel(int n,char *color)
{ if(fp!=NULL) fwrite(color,BytesPerPixel,n,fp);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/