本文整理汇总了C++中CImage::Assign方法的典型用法代码示例。如果您正苦于以下问题:C++ CImage::Assign方法的具体用法?C++ CImage::Assign怎么用?C++ CImage::Assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImage
的用法示例。
在下文中一共展示了CImage::Assign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetImageData
//
// Read image data
//
bool CCCDFile::GetImageData(CImage &img, CmpackBitpix bitpix, GError **error)
{
assert (m_Handle != NULL);
CmpackImage *i;
int res = cmpack_ccd_to_image(m_Handle, bitpix, &i);
if (res==0)
img.Assign(i);
else {
char *msg = cmpack_formaterror(res);
g_set_error(error, g_AppError, res, msg);
cmpack_free(msg);
}
return (res==0);
}
示例2: outputBuffer
//.........这里部分代码省略.........
}
imageFrameInfo[ i ].mipmapLevel = new TImageMipMapLevel[ currentFrame->nrOfMipmapLevels ];
for ( UInt32 n=0; n<currentFrame->nrOfMipmapLevels; ++n )
{
// Read the frame's mipmap info
TImageMipMapLevelInfo* mipMapLevel = &imageFrameInfo[ i ].mipmapLevel[ n ].mipLevelInfo;
bytesRead = bufferAccess.Read( mipMapLevel, sizeof( TImageMipMapLevelInfo ), 1 );
// Sanity check
if ( ( bytesRead != sizeof( TImageMipMapLevelInfo ) ) ||
( mipMapLevel->version != GUCEF_IMAGE_TIMAGEMIPMAPLEVELINFO_VERSION ) )
{
for ( UInt32 m=0; m<n; ++m ) delete []imageFrameInfo[ m ].mipmapLevel;
delete []imageFrameInfo;
return false;
}
}
}
// Now we can read all the pixel data
CImage::TFrameList frameList;
CImage::TMipMapList mipMapList;
UInt32 bufferOffset = bufferAccess.Tell();
char* pixelBuffer = static_cast< char* >( outputBuffer.GetBufferPtr() ) + bufferOffset;
for ( UInt32 i=0; i<imageInfo.nrOfFramesInImage; ++i )
{
TImageFrameInfo* currentFrame = &imageFrameInfo[ i ].frameInfo;
for ( UInt32 n=0; n<currentFrame->nrOfMipmapLevels; ++n )
{
// Create a pixelmap using the information we obtained + out pixelBuffer pointer
TImageMipMapLevelInfo* mipMapLevel = &imageFrameInfo[ i ].mipmapLevel[ n ].mipLevelInfo;
// Obtain the expected pixel map size in bytes
TPixelStorageFormat pixelStorageFormat = (TPixelStorageFormat) mipMapLevel->pixelStorageFormat;
TBuildinDataType pixelComponentDataType = (TBuildinDataType) mipMapLevel->pixelComponentDataType;
UInt32 pixelMapSize = CPixelMap::GetExpectedPixelMapSize( mipMapLevel->frameWidth ,
mipMapLevel->frameHeight ,
pixelStorageFormat ,
pixelComponentDataType );
// Check to make sure the buffer is large enough for the data we expect
if ( pixelMapSize <= outputBuffer.GetDataSize() - bufferOffset )
{
CPixelMap* pixelMap = new CPixelMap( pixelBuffer ,
mipMapLevel->frameWidth ,
mipMapLevel->frameHeight ,
pixelStorageFormat ,
pixelComponentDataType );
// Add this mipmap level to the frame
mipMapList.push_back( TPixelMapPtr( pixelMap ) );
if ( i+1 < imageInfo.nrOfFramesInImage )
{
// Jump to the next image component in the buffer
UInt32 pixelBlockSize = ( mipMapLevel->frameWidth * mipMapLevel->frameHeight ) * pixelMap->GetSizeOfPixelInBytes();
bufferOffset += pixelBlockSize;
if ( bufferOffset < outputBuffer.GetDataSize() )
{
pixelBuffer += pixelBlockSize;
}
else
{
// oh oh,.. we ran out of pixels in our buffer even though our image info
// suggests we should have more pixels
for ( UInt32 m=n; m<currentFrame->nrOfMipmapLevels; ++m ) delete []imageFrameInfo[ m ].mipmapLevel;
delete []imageFrameInfo;
return false;
}
}
}
else
{
// oh oh,.. we ran out of pixels in our buffer even though our image info
// suggests we should have more pixels
for ( UInt32 m=n; m<currentFrame->nrOfMipmapLevels; ++m ) delete []imageFrameInfo[ m ].mipmapLevel;
delete []imageFrameInfo;
return false;
}
}
// Add the frame with all it's mipmap levels to the frame list
frameList.push_back( mipMapList );
mipMapList.clear();
// Clean up our info storage
delete []imageFrameInfo[ i ].mipmapLevel;
}
// Clean up our info storage
delete []imageFrameInfo;
// Assign the parsed data to the output image object
outputImage.Assign( frameList );
return true;
}
return false;
}