Exemplo n.º 1
0
Image* ImageFactory::decodeFile(const char *file, PixelFormat format) {
	io::InputStream* is = new io::FileInputStream(file);
	Image* bitmap = decodeStream(is, format);
	is->close();
	delete is;
	return bitmap;
}
Exemplo n.º 2
0
bool SkAnimator::decodeURI(const char uri[]) {
//  SkDebugf("animator decode %s\n", uri);

//    SkStream* stream = SkStream::GetURIStream(fMaker->fPrefix.c_str(), uri);
    SkStream* stream = new SkFILEStream(uri);

    SkAutoTDelete<SkStream> autoDel(stream);
    setURIBase(uri);
    return decodeStream(stream);
}
Exemplo n.º 3
0
bool SkAnimator::decodeURI(const char uri[]) {
//  SkDebugf("animator decode %s\n", uri);

//    SkStream* stream = SkStream::GetURIStream(fMaker->fPrefix.c_str(), uri);
    SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(uri));
    if (stream.get()) {
        this->setURIBase(uri);
        return decodeStream(stream);
    } else {
        return false;
    }
}
Exemplo n.º 4
0
// differs from SkAnimator::decodeURI in that it does not set URI base
bool SkAnimateMaker::decodeURI(const char uri[]) {
//  SkDebugf("animator decode %s\n", uri);

//    SkStream* stream = SkStream::GetURIStream(fPrefix.c_str(), uri);
    SkStream* stream = new SkFILEStream(uri);

    SkAutoTDelete<SkStream> autoDel(stream);
    bool success = decodeStream(stream);
    if (hasError() && fError.hasNoun() == false)
        fError.setNoun(uri);
    return success;
}
Exemplo n.º 5
0
int BinTreeNodeReader::getOneToplevelStream()
{
    qint32 bufferSize = readInt24();
    qint8 flags = (bufferSize & 0xff0000) >> 20;
    bufferSize &= 0xffff;

    fillBuffer(bufferSize);

    //qDebug() << "[[ " + readBuffer.toHex();
    decodeStream(flags, 0, bufferSize);

    return bufferSize + 3;
}
Exemplo n.º 6
0
// differs from SkAnimator::decodeURI in that it does not set URI base
bool SkAnimateMaker::decodeURI(const char uri[]) {
//  SkDebugf("animator decode %s\n", uri);

//    SkStream* stream = SkStream::GetURIStream(fPrefix.c_str(), uri);
    SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(uri));
    if (stream.get()) {
        bool success = decodeStream(stream);
        if (hasError() && fError.hasNoun() == false)
            fError.setNoun(uri);
        return success;
    } else {
        return false;
    }
}
void SWDecoder::operator()()
{
	int res = 0;
	std::cout << "SWDecoder thread started" << std::endl;
	setupBuffer();
	setupCodec();

	while(!mFinish)
	{
		decodeStream();
		boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(5));
	}

	releaseCodec();
	std::cout << "SWDecoder thread stopped" << std::endl;
}
Exemplo n.º 8
0
bool SkAnimator::appendStream(SkStream* stream) {
    return decodeStream(stream);
}
Exemplo n.º 9
0
GIFError CGIFFile::ReadImage(GIFFrameBuffer &frame)
{
	GIFImageDescriptor	imageDesc;
	GIFError            status;

	BYTE blockSize;
	BYTE blockData[256];
	BYTE extension;

	bool done = false;
	BYTE label;

	while (!done) {
		status = readFromFile(&label, 1);
		if (status != GIF_Success)
			return status;

		switch (label) {
			case 0x2C:		// image descriptor
				status = readFromFile(&imageDesc, sizeof(imageDesc));
				if (status != GIF_Success)
					return status;

				if (imageDesc.PackedFields & GIFLocalMapPresent) {
					DWORD bitShift = (imageDesc.PackedFields & 0x07) + 1;
					frame.ColorMapEntryCount = 1 << bitShift;
					status = readFromFile(frame.ColorMap, 3 * frame.ColorMapEntryCount);
					if (status != GIF_Success)
						return status;
				}
				else {
					frame.ColorMapEntryCount = m_GlobalColorMapEntryCount;
					memcpy(frame.ColorMap, m_GlobalColorMap, m_GlobalColorMapEntryCount * 3);
				}

				// If the image is interlaced, then set these values
				// in preparation of calculating the proper offsets
				// for each line as it is read in.
				if (imageDesc.PackedFields & GIFInterlaced)
					m_IsInterlaced = true;
				else
					m_IsInterlaced = false;

				// Return the result of decoding, which should be GIF_Success,
				// to indicate that an image was successfully read.
				return decodeStream(frame, &imageDesc);

			case 0x21:		// extension block
				status = readFromFile(&extension, 1);
				if (status != GIF_Success)
					return status;

				switch (extension) {
					case 0x01:			//  plain text extension
						GIFTextExtension textExtension;
						status = readFromFile(&textExtension, sizeof(textExtension));
						if (status != GIF_Success)
							return status;

						do {
							status = readBlock(blockData, blockSize);
							if (status != GIF_Success)
								return status;
						} while (blockSize);
						break;

					case 0xF9:			// graphic control extension
						GIFControlExtension controlExtension;
						status = readFromFile(&controlExtension, sizeof(controlExtension));
						if (status != GIF_Success)
							return status;
						break;

					case 0xFE:			// comment extension
						do {
							status = readFromFile(&blockSize, 1);
							if (status != GIF_Success)
								return status;

							if (blockSize) {
								status = readFromFile(blockData, blockSize);
								if (status != GIF_Success)
									return status;
								blockData[blockSize] = '\0';
							}
						} while (blockSize);
						break;

					case 0xFF:			// application extension
						GIFApplicationExtension appExt;
						status = readFromFile(&appExt, sizeof(appExt));
						if (status != GIF_Success)
							return status;

						do {
							status = readFromFile(&blockSize, 1);
							if (status != GIF_Success)
								return status;
							if (blockSize) {
								status = readFromFile(blockData, blockSize);
								if (status != GIF_Success)
									return status;
							}
						} while (blockSize);
						break;

					default:
						return GIF_UnknownExtension;
				}
				break;

			// In the case of the file trailer, we know that we have reached the
			// end of the GIF file.  Return false to indicate that we are not able
			// to read any more images from the file.
			case 0x3B:		// trailer
				return GIF_NoImage;

			// If label is not recognized, then the file is either corrupt
			// or has some application-specific data present.  In either
			// case, abort any further reading.
			default:
				return GIF_UnknownLabel;
		}
	}

	return GIF_NoImage;
}