本文整理汇总了C++中FileStream::size方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStream::size方法的具体用法?C++ FileStream::size怎么用?C++ FileStream::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStream
的用法示例。
在下文中一共展示了FileStream::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadRawData
void* FileUtil::ReadRawData(const String& filepath, size_t &size)
{
FileStream file;
if(!file.open(filepath))
return 0;
size = file.size();
file.seek(0,Seek_begin);
binary data = reinterpret_cast<binary>(base_malloc(sizeof(byte)*size));
file.read(data,size);
return data;
}
示例2: cb_seek
int OggSoundFile::cb_seek(void* source, ogg_int64_t offset, int whence)
{
FileStream *file = static_cast<FileStream*>(source);
switch(whence) {
case SEEK_SET:
file->seek(offset);
return 0;
case SEEK_CUR:
file->seek(file->tell() + offset);
return 0;
case SEEK_END:
file->seek(file->size() + offset);
return 0;
}
return -1;
}
示例3: init
bool FontFreeType::init(const vn::FilePath &file, u32 size) {
FileStream *fs = FileManager::instance().open(file);
if (!fs) {
return false;
}
m_ftStream.descriptor.pointer = fs;
m_ftStream.size = (unsigned long)fs->size();
FT_Open_Args args = { FT_OPEN_STREAM };
args.stream = &m_ftStream;
if (FT_Open_Face(s_ftLibrary, &args, 0, &m_ftFace )) {
return false;
}
s32 height = (s32)((f32)(size << 6) * m_ftFace->units_per_EM / m_ftFace->height / 64.f);
FT_Select_Charmap(m_ftFace, FT_ENCODING_UNICODE);
FT_Set_Pixel_Sizes(m_ftFace, height, 0);
m_height = (s32)(m_ftFace->size->metrics.height >> 6);
m_baseLine = (s32)(m_ftFace->size->metrics.ascender >> 6);
m_texture = Render2DInterface::instance().createTexture(vector2i(kTexSize, kTexSize));
s32 cell = height + 2;
s32 cnt = kTexSize / cell;
for (s32 y = 0; y < cnt; ++y) {
for (s32 x = 0; x < cnt; ++x) {
GlyphEx *p = vnnew GlyphEx();
p->valid = false;
p->size.y = (real)m_height;
p->texture = m_texture;
p->pos.set(x * cell + 1, y * cell + 1);
p->texcoord.min_corner = vector2f(p->pos) / kTexSize;
p->pass = 0;
m_glyphList.push_front(p);
p->lstIt = m_glyphList.begin();
p->mapIt = m_glyphMap.end();
}
}
return true;
}
示例4: VCRDecoder
VCRDecoder()
{
FileStream inputStream = File("U:\\c2.raw", true).openRead();
//FileStream inputStream = File("U:\\captured.bin", true).openRead();
int nn = inputStream.size();
FileStream h = File("U:\\vcr_decoded.bin", true).openWrite();
int samplesPerFrame = 1824*253;
Array<Byte> input(samplesPerFrame);
_fftData.allocate(2048);
_chromaData.allocate(2048);
_burstData.allocate(91);
_forward = fftwf_plan_dft_1d(2048, reinterpret_cast<fftwf_complex*>(&_fftData[0]), reinterpret_cast<fftwf_complex*>(&_fftData[0]), -1, FFTW_MEASURE);
_backward = fftwf_plan_dft_1d(2048, reinterpret_cast<fftwf_complex*>(&_fftData[0]), reinterpret_cast<fftwf_complex*>(&_fftData[0]), 1, FFTW_MEASURE);
_chromaForward = fftwf_plan_dft_1d(2048, reinterpret_cast<fftwf_complex*>(&_chromaData[0]), reinterpret_cast<fftwf_complex*>(&_chromaData[0]), -1, FFTW_MEASURE);
_chromaBackward = fftwf_plan_dft_1d(2048, reinterpret_cast<fftwf_complex*>(&_chromaData[0]), reinterpret_cast<fftwf_complex*>(&_chromaData[0]), 1, FFTW_MEASURE);
Complex<float> localOscillatorFrequency = unit(4.4f*11/315);
Complex<float> chromaOscillatorFrequency = unit(2.0f/91); // 0.629 == 315/11 / 2 / 4 * 16 / 91 0.629f*11/315 == 16/8/91
//static const float cutoff = 3.0f*2048*11/315; // 3.3f
//static const int cutoff = 208;
static const int cutoff = static_cast<int>(2.2f*2048*11/315);
static const int chromaCutoff = static_cast<int>(2048.0*2.0/91)*0.75; // *0.5;
_outputb0.allocate(2048);
_outputb1.allocate(2048);
Array<Complex<float>> amplitudes(253);
for (int y = 0; y < 253; ++y)
amplitudes[y] = 0;
Array<Vector3<float>> frameCache(3*2048*253);
for (int i = 0; i < 3*2048*253; ++i)
frameCache[i] = Vector3<float>(0, 0, 0);
int frame = 0;
Complex<float> burstAcc = 0;
Complex<float> framePhase = unit((90 - 33)/360.0f);
}
示例5: run
void run()
{
bool doDecode = false;
static const int samples = 450*1024;
static const int inputBufferSize = samples;
static const int sampleSpaceBefore = 256;
static const int sampleSpaceAfter = 256;
FileStream in = File("captured.zdr", true).openRead();
UInt64 inputFileSizeRemaining = in.size();
Array<Byte> inputBuffer(inputBufferSize);
int inputBufferRemaining = 0;
Byte* inputPointer = 0;
z_stream zs;
memset(&zs, 0, sizeof(z_stream));
if (inflateInit(&zs) != Z_OK)
throw Exception("inflateInit failed");
Array<Byte> buffer(sampleSpaceBefore + samples + sampleSpaceAfter);
Byte* b = &buffer[0] + sampleSpaceBefore;
for (int i = 0; i < sampleSpaceBefore; ++i)
b[i - sampleSpaceBefore] = 0;
for (int i = 0; i < sampleSpaceAfter; ++i)
b[i + samples] = 0;
int outputBytesRemaining = samples;
Vector outputSize;
NTSCCaptureDecoder<UInt32> decoder;
if (doDecode)
outputSize = Vector(960, 240);
else
outputSize = Vector(1824, 253);
Bitmap<UInt32> decoded(outputSize);
decoder.setOutputBuffer(decoded);
decoded.fill(0);
decoder.setInputBuffer(b);
decoder.setOutputPixelsPerLine(1140);
decoder.setYScale(1);
decoder.setDoDecode(doDecode);
FileStream outputStream = File("u:\\captured.bin", true).openWrite();
do {
if (inputBufferRemaining == 0) {
int bytesToRead = inputBufferSize;
if (bytesToRead > inputFileSizeRemaining)
bytesToRead = inputFileSizeRemaining;
inputPointer = &inputBuffer[0];
in.read(inputPointer, bytesToRead);
inputBufferRemaining = bytesToRead;
inputFileSizeRemaining -= bytesToRead;
}
zs.avail_in = inputBufferRemaining;
zs.next_in = inputPointer;
zs.avail_out = outputBytesRemaining;
zs.next_out = b + samples - outputBytesRemaining;
int r = inflate(&zs, Z_SYNC_FLUSH);
if (r != Z_STREAM_END && r != Z_OK)
throw Exception("inflate failed");
outputBytesRemaining = zs.avail_out;
inputPointer = zs.next_in;
inputBufferRemaining = zs.avail_in;
if (outputBytesRemaining == 0) {
if (inflateReset(&zs) != Z_OK)
throw Exception("inflateReset failed");
outputBytesRemaining = samples;
console.write(".");
if (doDecode) {
decoder.decode();
outputStream.write(decoded.data(), decoded.stride()*outputSize.y);
}
else
outputStream.write(b, 1824*253);
}
} while (inputFileSizeRemaining != 0);
if (inflateEnd(&zs) != Z_OK)
throw Exception("inflateEnd failed");
}