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


C++ CTFileStream::Write_t方法代码示例

本文整理汇总了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);
}
开发者ID:0-T-0,项目名称:Serious-Engine,代码行数:47,代码来源:ImageInfo.cpp


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