当前位置: 首页>>代码示例>>C++>>正文


C++ ZStreamW::Write方法代码示例

本文整理汇总了C++中ZStreamW::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ ZStreamW::Write方法的具体用法?C++ ZStreamW::Write怎么用?C++ ZStreamW::Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZStreamW的用法示例。


在下文中一共展示了ZStreamW::Write方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sWriteColorTable

static void sWriteColorTable(const ZStreamW& iStream,
	const ZRGBColorPOD* iColors, size_t iCountAvailable, size_t iCountNeeded)
	{
	iCountAvailable = min(iCountAvailable, iCountNeeded);

	vector<uint8> tempColorsVector(iCountNeeded * 3);
	uint8* currentDest = &tempColorsVector[0];

	for (size_t x = 0; x < iCountAvailable; ++x)
		{
		*currentDest++ = iColors->red >> 8;
		*currentDest++ = iColors->green >> 8;
		*currentDest++ = iColors->blue >> 8;
		++iColors;
		}

	for (size_t x = iCountAvailable; x < iCountNeeded; ++x)
		{
		*currentDest++ = 0;
		*currentDest++ = 0;
		*currentDest++ = 0;
		}

	iStream.Write(&tempColorsVector[0], tempColorsVector.size());
	}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: sWriteString

static void sWriteString(const ZStreamW& iStreamW, const string& iString)
	{
	size_t theSize = iString.size();
	sWriteCount(iStreamW, theSize);
	if (theSize)
		iStreamW.Write(iString.data(), theSize);
	}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例3: spWriteFreeFlush

static void spWriteFreeFlush(SecBuffer& sb, const ZStreamW& w)
{
    if (not sb.pvBuffer)
        return;

    if (not sb.cbBuffer)
    {
        spPSFT->FreeContextBuffer(sb.pvBuffer);
        sb.pvBuffer = nullptr;
    }
    else
    {
        size_t countWritten = 0;
        w.Write(sb.pvBuffer, sb.cbBuffer, &countWritten);

        const bool shortWrite = (countWritten != sb.cbBuffer);
        sb.cbBuffer = 0;

        spPSFT->FreeContextBuffer(sb.pvBuffer);
        sb.pvBuffer = nullptr;

        if (shortWrite)
            ZStreamW::sThrowEndOfStream();
        w.Flush();
    }
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例4: pCopyTo

void ZStreamR_Memory::pCopyTo(const ZStreamW& iStreamW, uint64 iCount,
	uint64* oCountRead, uint64* oCountWritten)
	{
	if (oCountRead)
		*oCountRead = 0;
	if (oCountWritten)
		*oCountWritten = 0;
	while (iCount)
		{
		size_t countWritten;
		iStreamW.Write(fAddress, iCount, &countWritten);
		if (countWritten == 0)
			break;
		fAddress += countWritten;
		iCount -= countWritten;
		if (oCountRead)
			*oCountRead += countWritten;
		if (oCountWritten)
			*oCountWritten += countWritten;
		}
	}
开发者ID:,项目名称:,代码行数:21,代码来源:

示例5: Imp_Write

void ZDCPixmapEncoder_GIF::Imp_Write(const ZStreamW& iStream,
	const void* iBaseAddress,
	const ZDCPixmapNS::RasterDesc& iRasterDesc,
	const ZDCPixmapNS::PixelDesc& iPixelDesc,
	const ZRect& iBounds)
	{
	ZRef<ZDCPixmapNS::PixelDescRep_Indexed> thePixelDescRep_Indexed
		= ZRefDynamicCast<ZDCPixmapNS::PixelDescRep_Indexed>(iPixelDesc.GetRep());
	ZAssertStop(2, thePixelDescRep_Indexed);

	if (fTransparent)
		iStream.WriteString("GIF89a");
	else
		iStream.WriteString("GIF87a");
	iStream.WriteUInt16LE(iBounds.Width());
	iStream.WriteUInt16LE(iBounds.Height());

	uint8 globalStrmFlags = 0;
	globalStrmFlags |= 0x80; // hasGlobalColorTable
	globalStrmFlags |= 0x70; // colorResolution (8 bits per component)
	// globalStrmFlags |= 0x08; // set this if the color table is sorted in priority order

	ZAssertStop(2, iRasterDesc.fPixvalDesc.fDepth > 0 && iRasterDesc.fPixvalDesc.fDepth <= 8);
	
	globalStrmFlags |= iRasterDesc.fPixvalDesc.fDepth - 1; // globalColorTableSize & depth
	iStream.WriteUInt8(globalStrmFlags);

	iStream.WriteUInt8(0); // backgroundColorIndex
	iStream.WriteUInt8(0); // Pixel aspect ratio -- 0 == none specified.

	const ZRGBColorPOD* theColors;
	size_t theColorsCount;
	thePixelDescRep_Indexed->GetColors(theColors, theColorsCount);
	sWriteColorTable(iStream, theColors, theColorsCount, 1 << iRasterDesc.fPixvalDesc.fDepth);

	if (fTransparent)
		{
		iStream.WriteUInt8('!'); // Extension block
		iStream.WriteUInt8(0xF9); // Graphic Control Extension
		iStream.WriteUInt8(4); // Block size
		// The next byte encodes four fields:
		// 3 bits, Reserved == 0
		// 3 bits, Disposal Method == none (0),
		// 1 bit, User Input Flag == none (0)
		// 1 bit, Transparent Color Flag = yes (1)
		iStream.WriteUInt8(1);
		iStream.WriteUInt16LE(0); // Delay time
		iStream.WriteUInt8(fTransparentPixval);
		iStream.WriteUInt8(0); // Block terminator
		}

	iStream.WriteUInt8(','); // Start of image
	iStream.WriteUInt16LE(0); // Origin h
	iStream.WriteUInt16LE(0); // Origin v
	iStream.WriteUInt16LE(iBounds.Width());
	iStream.WriteUInt16LE(iBounds.Height());

	uint8 localStrmFlags = 0;
//	localStrmFlags |= 0x80; // hasLocalColorTable
	if (fInterlace)
		localStrmFlags |= 0x40; // interlaced
//	localStrmFlags |= 0x20; // sorted
//	localStrmFlags |= 0x70; // localColorTableSize
	iStream.WriteUInt8(localStrmFlags);

	iStream.WriteUInt8(iRasterDesc.fPixvalDesc.fDepth); // Initial code size.

	{ // Scope theSC.
	StreamW_Chunk theSC(iStream);

	ZStreamW_LZWEncode* theSLZW = nil;
	ZStreamW_LZWEncodeNoPatent* theSLZWNP = nil;

	ZStreamW* theStream;
	if (fNoPatent)
		{
		theSLZWNP = new ZStreamW_LZWEncodeNoPatent(iRasterDesc.fPixvalDesc.fDepth, theSC);
		theStream = theSLZWNP;
		}
	else
		{
		theSLZW = new ZStreamW_LZWEncode(iRasterDesc.fPixvalDesc.fDepth, theSC);
		theStream = theSLZW;
		}

	ZDCPixmapNS::PixvalDesc destPixvalDesc(8, true);

	vector<uint8> theRowBufferVector(iBounds.Width());
	void* theRowBuffer = &theRowBufferVector[0];

	try
		{
		if (fInterlace)
			{
			for (int pass = 0; pass < 4; ++pass)
				{
				for (ZCoord currentY = iBounds.top + sInterlaceStart[pass];
					currentY < iBounds.bottom; currentY += sInterlaceIncrement[pass])
					{
					const void* sourceRowAddress
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例6: sCopyReadToWrite

/**
Copy data from \a iStreamR to \a iStreamW by reading it into a buffer and writing
from that buffer. If more than 8K is to be copied we try to allocate an 8K buffer
in the heap. If less than 8K is to be copied, or the heap buffer could not be allocated,
we use a 1K buffer on the stack.
*/
void sCopyReadToWrite(const ZStreamR& iStreamR, const ZStreamW& iStreamW, uint64 iCount,
	uint64* oCountRead, uint64* oCountWritten)
	{
	if (oCountRead)
		*oCountRead = 0;
	if (oCountWritten)
		*oCountWritten = 0;

	if (iCount == 0)
		return;

	if (iCount > 8192)
		{
		// Try to allocate and use an 8K heap-based buffer.
		if (uint8* heapBuffer = new(nothrow) uint8[8192])
			{
			try
				{
				uint64 countRemaining = iCount;
				while (countRemaining > 0)
					{
					size_t countRead;
					iStreamR.Read(heapBuffer, min(countRemaining, uint64(8192)), &countRead);
					if (countRead == 0)
						break;
					if (oCountRead)
						*oCountRead += countRead;
					countRemaining -= countRead;
					uint8* tempSource = heapBuffer;
					while (countRead > 0)
						{
						size_t countWritten;
						iStreamW.Write(tempSource, countRead, &countWritten);
						if (countWritten == 0)
							{
							countRemaining = 0;
							break;
							}
						tempSource += countWritten;
						countRead -= countWritten;
						if (oCountWritten)
							*oCountWritten += countWritten;
						}
					}
				}
			catch (...)
				{
				delete[] heapBuffer;
				throw;
				}
			delete[] heapBuffer;
			return;
			}
		}

	// We'll get to here if we need to move 8192 bytes or less, or if
	// allocation of the heap buffer failed.

	// Use a stack-based 1024 byte buffer if we're moving less than 8K and thus will iterate
	// fewer than 8 times. Previously we'd unconditionally used one of size 4096, but that's
	// fairly large and can contribute to blowing the stack on MacOS.
	uint8 localBuffer[1024];
	uint64 countRemaining = iCount;
	while (countRemaining > 0)
		{
		size_t countRead;
		iStreamR.Read(localBuffer, min(countRemaining, uint64(sizeof(localBuffer))), &countRead);
		if (countRead == 0)
			break;
		if (oCountRead)
			*oCountRead += countRead;
		countRemaining -= countRead;
		uint8* tempSource = localBuffer;
		while (countRead > 0)
			{
			size_t countWritten;
			iStreamW.Write(tempSource, countRead, &countWritten);
			if (countWritten == 0)
				{
				countRemaining = 0;
				break;
				}
			tempSource += countWritten;
			countRead -= countWritten;
			if (oCountWritten)
				*oCountWritten += countWritten;
			}
		}
	}
开发者ID:,项目名称:,代码行数:95,代码来源:

示例7: spWriteFully

static bool spWriteFully(const SecBuffer& sb, const ZStreamW& w)
{
    size_t countWritten;
    w.Write(sb.pvBuffer, sb.cbBuffer, &countWritten);
    return countWritten == sb.cbBuffer;
}
开发者ID:,项目名称:,代码行数:6,代码来源:


注:本文中的ZStreamW::Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。