本文整理汇总了C++中CTFileStream::Write_t方法的典型用法代码示例。如果您正苦于以下问题:C++ CTFileStream::Write_t方法的具体用法?C++ CTFileStream::Write_t怎么用?C++ CTFileStream::Write_t使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTFileStream
的用法示例。
在下文中一共展示了CTFileStream::Write_t方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveTGA_t
// save TGA routine
void CImageInfo::SaveTGA_t( const CTFileName &strFileName) const // throw char *
{
TGAHeader *pTGAHdr;
UBYTE *pTGABuffer, *pTGAImage;
SLONG slFileSize;
PIX pixBitmapSize = ii_Width*ii_Height;
CTFileStream TGAFile;
// determine and check image info format
SLONG slBytesPerPixel = ii_BitsPerPixel/8;
ASSERT( slBytesPerPixel==3 || slBytesPerPixel==4);
if( slBytesPerPixel!=3 && slBytesPerPixel!=4) throw( TRANS( "Unsupported BitsPerPixel in ImageInfo header."));
// determine TGA file size and allocate memory
slFileSize = sizeof(struct TGAHeader) + pixBitmapSize *slBytesPerPixel;
pTGABuffer = (UBYTE*)AllocMemory( slFileSize);
pTGAHdr = (struct TGAHeader*)pTGABuffer;
pTGAImage = pTGABuffer + sizeof(struct TGAHeader);
// set TGA picture size dimensions
memset( pTGABuffer, 0x0, sizeof(struct TGAHeader));
pTGAHdr->Width = (UWORD)ii_Width;
pTGAHdr->Height = (UWORD)ii_Height;
pTGAHdr->BitsPerPixel = (UBYTE)ii_BitsPerPixel;
pTGAHdr->ImageType = 2;
// flip image vertically
BOOL bAlphaChannel = (slBytesPerPixel==4);
FlipBitmap( ii_Picture, pTGAImage, ii_Width, ii_Height, 1, bAlphaChannel);
// convert CroTeam's pixel format to TGA format
UBYTE *pubTmp = pTGAImage; // need 'walking' pointer
for( INDEX iPix=0; iPix<pixBitmapSize; iPix++)
{ // flip bytes
Swap( pubTmp[0], pubTmp[2]); // R & B channels
pubTmp += slBytesPerPixel;
}
// save entire TGA memory to file and close it
TGAFile.Create_t( strFileName);
TGAFile.Write_t( pTGABuffer, slFileSize);
TGAFile.Close();
// free temorary allocated memory for TGA image format
FreeMemory( pTGABuffer);
}