本文整理汇总了C++中cfread函数的典型用法代码示例。如果您正苦于以下问题:C++ cfread函数的具体用法?C++ cfread怎么用?C++ cfread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cfread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gr_use_palette_table
void gr_use_palette_table( char * filename )
{
CFILE *fp;
int i,fsize;
fp = cfopen( filename, "rb" );
if ( fp==NULL)
Error("Can't open palette file <%s>",filename);
fsize = cfilelength( fp );
Assert( fsize == 9472 );
cfread( gr_palette, 256*3, 1, fp );
cfread( gr_fade_table, 256*34, 1, fp );
cfclose(fp);
// This is the TRANSPARENCY COLOR
for (i=0; i<GR_FADE_LEVELS; i++ ) {
gr_fade_table[i*256+255] = 255;
}
Num_computed_colors = 0; // Flush palette cache.
#if defined(POLY_ACC)
pa_update_clut(gr_palette, 0, 256, 0);
#endif
}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:25,代码来源:palette.c
示例2: pcx_read_header
// reads header information from the PCX file into the bitmap pointer
int pcx_read_header(char *real_filename, int *w, int *h, ubyte *pal )
{
PCXHeader header;
CFILE * PCXfile;
char filename[MAX_FILENAME_LEN];
strcpy( filename, real_filename );
char *p = strchr( filename, '.' );
if ( p ) *p = 0;
strcat( filename, ".pcx" );
PCXfile = cfopen( filename , "rb" );
if ( !PCXfile )
return PCX_ERROR_OPENING;
// read 128 char PCX header
if (cfread( &header, sizeof(PCXHeader), 1, PCXfile )!=1) {
cfclose( PCXfile );
return PCX_ERROR_NO_HEADER;
}
header.Xmin = INTEL_SHORT( header.Xmin );
header.Ymin = INTEL_SHORT( header.Ymin );
header.Xmax = INTEL_SHORT( header.Xmax );
header.Ymax = INTEL_SHORT( header.Ymax );
header.Hdpi = INTEL_SHORT( header.Hdpi );
header.Vdpi = INTEL_SHORT( header.Vdpi );
for ( int i=0; i<16; i++ ){
for ( int j=0; j<3; j++){
header.ColorMap[i][j] = INTEL_INT( header.ColorMap[i][j] );
}
}
header.BytesPerLine = INTEL_SHORT( header.BytesPerLine );
for ( int i=0; i<60; i++ ){
header.filler[i] = INTEL_INT( header.filler[i] );
}
// Is it a 256 color PCX file?
if ((header.Manufacturer != 10)||(header.Encoding != 1)||(header.Nplanes != 1)||(header.BitsPerPixel != 8)||(header.Version != 5)) {
cfclose( PCXfile );
return PCX_ERROR_WRONG_VERSION;
}
if (w) *w = header.Xmax - header.Xmin + 1;
if (h) *h = header.Ymax - header.Ymin + 1;
if ( pal ) {
cfseek( PCXfile, -768, CF_SEEK_END );
cfread( pal, 3, 256, PCXfile );
}
cfclose(PCXfile);
return PCX_ERROR_NONE;
}
开发者ID:lubomyr,项目名称:freespace2,代码行数:54,代码来源:pcxutils.cpp
示例3: gr_use_palette_table
void gr_use_palette_table( char * filename )
{
CFILE *fp;
int i,fsize;
#ifdef SWAP_0_255
ubyte c;
#endif
fp = cfopen( filename, "rb" );
// the following is a hack to enable the loading of d2 levels
// even if only the d2 mac shareware datafiles are present.
// However, if the pig file is present but the palette file isn't,
// the textures in the level will look wierd...
if ( fp==NULL)
fp = cfopen( DEFAULT_LEVEL_PALETTE, "rb" );
if ( fp==NULL)
Error("Can open neither palette file <%s> "
"nor default palette file <"
DEFAULT_LEVEL_PALETTE
">.\n",
filename);
fsize = cfilelength( fp );
Assert( fsize == 9472 );
cfread( gr_palette, 256*3, 1, fp );
cfread( gr_fade_table, 256*34, 1, fp );
cfclose(fp);
// This is the TRANSPARENCY COLOR
for (i=0; i<GR_FADE_LEVELS; i++ ) {
gr_fade_table[i*256+255] = 255;
}
Num_computed_colors = 0; // Flush palette cache.
// swap colors 0 and 255 of the palette along with fade table entries
#ifdef SWAP_0_255
for (i = 0; i < 3; i++) {
c = gr_palette[i];
gr_palette[i] = gr_palette[765+i];
gr_palette[765+i] = c;
}
for (i = 0; i < GR_FADE_LEVELS * 256; i++) {
if (gr_fade_table[i] == 0)
gr_fade_table[i] = 255;
}
for (i=0; i<GR_FADE_LEVELS; i++)
gr_fade_table[i*256] = TRANSPARENCY_COLOR;
#endif
}
开发者ID:btb,项目名称:d2x,代码行数:52,代码来源:palette.c
示例4: piggy_read_sounds
void piggy_read_sounds()
{
ubyte * ptr;
int i, sbytes;
ptr = SoundBits;
sbytes = 0;
for (i=0; i<Num_sound_files; i++ ) {
digi_sound *snd = &GameSounds[i];
if ( SoundOffset[i] > 0 ) {
if ( piggy_is_needed(i) ) {
cfseek( Piggy_fp, SoundOffset[i], SEEK_SET );
// Read in the sound data!!!
snd->data = ptr;
ptr += snd->length;
sbytes += snd->length;
cfread( snd->data, snd->length, 1, Piggy_fp );
}
}
}
mprintf(( 0, "\nActual Sound usage: %d KB\n", sbytes/1024 ));
}
开发者ID:devint1,项目名称:Descent-Mobile,代码行数:27,代码来源:piggy.c
示例5: anim_instance_get_byte
unsigned char anim_instance_get_byte(anim_instance *ai, int offset)
{
int absolute_offset;
anim *parent;
Assert(ai);
Assert(ai->parent->cfile_ptr);
Assert(ai->parent->flags & ANF_STREAMED);
parent = ai->parent;
absolute_offset = ai->file_offset + offset;
// maybe in cache?
int cache_offset;
cache_offset = absolute_offset - parent->cache_file_offset;
if ( (cache_offset >= 0) && (cache_offset < ANI_STREAM_CACHE_SIZE) ) {
return parent->cache[cache_offset];
} else {
// fill cache
cfseek(parent->cfile_ptr, absolute_offset, CF_SEEK_SET);
cfread(parent->cache, ANI_STREAM_CACHE_SIZE, 1, parent->cfile_ptr);
parent->cache_file_offset = absolute_offset;
return parent->cache[0];
}
}
开发者ID:X3N0-Life-Form,项目名称:fs2open.github.com,代码行数:25,代码来源:animplay.cpp
示例6: palette_load_table
void palette_load_table( char * filename )
{
int i;
int w, h;
int pcx_error;
strcpy( palette_base_filename, filename );
char * p = strchr(palette_base_filename,'.');
if ( p ) {
*p = 0;
}
pcx_error = pcx_read_header(palette_base_filename, NULL, &w, &h, NULL, palette_org );
if ( pcx_error != PCX_ERROR_NONE ) {
// Read the old .256 file
CFILE *fp;
int fsize;
fp = cfopen( palette_base_filename, "rb" );
if ( fp==NULL)
Error( LOCATION, "Can't open palette file <%s>",palette_base_filename);
fsize = cfilelength( fp );
Assert( fsize == 9472 );
cfread( palette_org, 256*3, 1, fp );
cfclose(fp);
for (i=0; i<768; i++ ) {
palette_org[i] = ubyte((palette_org[i]*255)/63);
}
}
palette_base_loaded = 1;
gr_set_palette(palette_base_filename, palette_org);
}
开发者ID:svn2github,项目名称:FS2Open_Trunk,代码行数:35,代码来源:palman.cpp
示例7: polymodel_read
/*
* reads a polymodel structure from a CFILE
*/
extern void polymodel_read(polymodel *pm, CFILE *fp)
{
int i;
pm->n_models = cfile_read_int(fp);
pm->model_data_size = cfile_read_int(fp);
pm->model_data = (ubyte *) cfile_read_int(fp);
for (i = 0; i < MAX_SUBMODELS; i++)
pm->submodel_ptrs[i] = cfile_read_int(fp);
for (i = 0; i < MAX_SUBMODELS; i++)
cfile_read_vector(&(pm->submodel_offsets[i]), fp);
for (i = 0; i < MAX_SUBMODELS; i++)
cfile_read_vector(&(pm->submodel_norms[i]), fp);
for (i = 0; i < MAX_SUBMODELS; i++)
cfile_read_vector(&(pm->submodel_pnts[i]), fp);
for (i = 0; i < MAX_SUBMODELS; i++)
pm->submodel_rads[i] = cfile_read_fix(fp);
cfread(pm->submodel_parents, MAX_SUBMODELS, 1, fp);
for (i = 0; i < MAX_SUBMODELS; i++)
cfile_read_vector(&(pm->submodel_mins[i]), fp);
for (i = 0; i < MAX_SUBMODELS; i++)
cfile_read_vector(&(pm->submodel_maxs[i]), fp);
cfile_read_vector(&(pm->mins), fp);
cfile_read_vector(&(pm->maxs), fp);
pm->rad = cfile_read_fix(fp);
pm->n_textures = cfile_read_byte(fp);
pm->first_texture = cfile_read_short(fp);
pm->simpler_model = cfile_read_byte(fp);
}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:32,代码来源:polyobj.c
示例8: bitfile_readbits
int bitfile_readbits(BITFILE * b, size_t length) {
int result;
int left;
char ch;
unsigned int mask;
result = 0;
do {
if (b->bitoffset == 0) {
cfread(& (b->currentchar), 1, b->fp);
}
mask = (1 << length) - 1;
left = BYTEBITS - b->bitoffset - length;
if (left > 0) {
// 'left' bits remain in this byte
ch = b->currentchar >> left;
b->bitoffset = (b->bitoffset + length) % BYTEBITS;
length = 0;
} else {
// abs(left) bits are in the next byte
left = abs(left);
ch = b->currentchar << left;
b->bitoffset = (b->bitoffset + length - left) % BYTEBITS;
length = left;
}
result |= ch & mask;
} while (length);
开发者ID:Sjord,项目名称:checkmate,代码行数:27,代码来源:bitfile.c
示例9: cfread_int
void pilotfile_convert::plr_import_hud()
{
int idx;
conv_color c;
plr->hud_show_flags = cfread_int(cfp);
plr->hud_show_flags2 = cfread_int(cfp);
plr->hud_popup_flags = cfread_int(cfp);
plr->hud_popup_flags2 = cfread_int(cfp);
plr->hud_num_lines = cfread_ubyte(cfp);
plr->hud_rp_flags = cfread_int(cfp);
plr->hud_rp_dist = cfread_int(cfp);
for (idx = 0; idx < 39; idx++) {
cfread(&c, sizeof(conv_color), 1, cfp);
if ( (c.alphacolor != -1) || (c.is_alphacolor != 1) ) {
throw "Data check failure in hud!";
}
plr->hud_colors[idx][0] = c.red;
plr->hud_colors[idx][1] = c.green;
plr->hud_colors[idx][2] = c.blue;
plr->hud_colors[idx][3] = c.alpha;
}
}
开发者ID:achilleas-k,项目名称:fs2open.github.com,代码行数:28,代码来源:plr_convert.cpp
示例10: cfile_read_byte
byte cfile_read_byte(CFILE *file)
{
byte b;
if (cfread( &b, sizeof(b), 1, file) != 1)
Error( "Error reading byte in cfile_read_byte()" );
return b;
}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:9,代码来源:cfile.c
示例11: read_byte
static byte read_byte(CFILE *file)
{
byte b;
if (cfread( &b, sizeof(b), 1, file) != 1)
Error( "Error reading byte in gamesave.c" );
return b;
}
开发者ID:NonCreature0714,项目名称:descent2,代码行数:9,代码来源:GAMEMINE.C
示例12: read_fix
static fix read_fix(CFILE *file)
{
fix f;
if (cfread( &f, sizeof(f), 1, file) != 1)
Error( "Error reading fix in gamesave.c" );
f = (fix)INTEL_INT((int)f);
return f;
}
开发者ID:NonCreature0714,项目名称:descent2,代码行数:10,代码来源:GAMEMINE.C
示例13: cfile_read_fixang
fixang cfile_read_fixang(CFILE *file)
{
fixang f;
if (cfread(&f, 2, 1, file) != 1)
Error("Error reading fixang in cfile_read_fixang()");
f = (fixang) INTEL_SHORT((int) f);
return f;
}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:10,代码来源:cfile.c
示例14: cfile_read_fix
fix cfile_read_fix(CFILE *file)
{
fix f;
if (cfread( &f, sizeof(f), 1, file) != 1)
Error( "Error reading fix in cfile_read_fix()" );
f = (fix)INTEL_INT((int)f);
return f;
}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:10,代码来源:cfile.c
示例15: cfile_read_short
short cfile_read_short(CFILE *file)
{
int16_t s;
if (cfread( &s, sizeof(s), 1, file) != 1)
Error( "Error reading short in cfile_read_short()" );
s = INTEL_SHORT(s);
return s;
}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:10,代码来源:cfile.c
示例16: cfile_read_int
int cfile_read_int(CFILE *file)
{
int32_t i;
if (cfread( &i, sizeof(i), 1, file) != 1)
Error( "Error reading int in cfile_read_int()" );
i = INTEL_INT(i);
return i;
}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:10,代码来源:cfile.c
示例17: read_short
static short read_short(CFILE *file)
{
short s;
if (cfread( &s, sizeof(s), 1, file) != 1)
Error( "Error reading short in gamesave.c" );
s = INTEL_SHORT(s);
return s;
}
开发者ID:NonCreature0714,项目名称:descent2,代码行数:10,代码来源:GAMEMINE.C
示例18: gr_use_palette_table
void gr_use_palette_table( char * filename )
{
CFILE *fp;
int i,fsize;
fp = cfopen( filename, "rb" );
if ( fp==NULL)
Error("Can't open palette file <%s>",filename);
fsize = cfilelength( fp );
Assert( fsize == 9472 );
cfread( gr_palette, 256*3, 1, fp );
cfread( gr_fade_table, 256*34, 1, fp );
cfclose(fp);
// This is the TRANSPARENCY COLOR
for (i=0; i<GR_FADE_LEVELS; i++ ) {
gr_fade_table[i*256+255] = 255;
}
}
开发者ID:arbruijn,项目名称:d1xnacl,代码行数:20,代码来源:palette.c
示例19: fiction_viewer_load
void fiction_viewer_load(const char *filename, const char *font_filename, const char *voice_filename)
{
int file_length;
Assertion(filename, "Invalid fictionviewer filename pointer given!");
Assertion(font_filename, "Invalid fictionviewer font filename pointer given!");
Assertion(voice_filename, "Invalid fictionviewer voice filename pointer given!");
// just to be sure
if (Fiction_viewer_text != NULL)
{
Int3();
fiction_viewer_reset();
}
// save our filenames
strcpy_s(Fiction_viewer_filename, filename);
strcpy_s(Fiction_viewer_font_filename, font_filename);
strcpy_s(Fiction_viewer_voice_filename, voice_filename);
// see if we have a matching font
Fiction_viewer_fontnum = gr_get_fontnum(Fiction_viewer_font_filename);
if (Fiction_viewer_fontnum < 0 && !Fred_running)
strcpy_s(Fiction_viewer_font_filename, "");
Fiction_viewer_voice = audiostream_open(Fiction_viewer_voice_filename, ASF_VOICE);
if (Fiction_viewer_voice < 0 && !Fred_running)
strcpy_s(Fiction_viewer_voice_filename, "");
if (!strlen(filename))
return;
// load up the text
CFILE *fp = cfopen(filename, "rb", CFILE_NORMAL, CF_TYPE_FICTION);
if (fp == NULL)
{
Warning(LOCATION, "Unable to load fiction file '%s'.", filename);
return;
}
// we don't need to copy the text in Fred
if (!Fred_running)
{
// allocate space
file_length = cfilelength(fp);
Fiction_viewer_text = (char *) vm_malloc(file_length + 1);
Fiction_viewer_text[file_length] = '\0';
// copy all the text
cfread(Fiction_viewer_text, file_length, 1, fp);
}
// we're done, close it out
cfclose(fp);
}
开发者ID:DahBlount,项目名称:Freespace-Open-Swifty,代码行数:54,代码来源:fictionviewer.cpp
示例20: cfread_compressed
// cfread() reads from a file and decompresses it
//
// returns: returns the number of full elements read
//
//
int cfread_compressed(void *buf, int elsize, int nelem, CFILE *cfile)
{
char *out = (char *)buf;
while(1) {
byte count;
if ( cfread( &count, 1, 1, cfile ) != 1 ) {
break;
}
int run_span = count & 0x80;
count &= (~0x80);
count++;
if ( count > 0 ) {
if ( run_span ) {
// RLE'd data
byte c;
if ( cfread( &c, 1, 1, cfile ) != 1 ) {
break;
}
memset( out, c, count );
} else {
if ( cfread( out, 1, count, cfile ) != count ) {
break;
}
}
out += count;
if ( out >= (char *)buf + (elsize*nelem)) {
break;
}
} else {
break;
}
}
return (out - (char *)buf)/elsize;
}
开发者ID:lubomyr,项目名称:freespace2,代码行数:45,代码来源:cfilelist.cpp
注:本文中的cfread函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论