Ejemplo n.º 1
0
/*!
Tries to store the raster data to the given mem block.
Will include a ImageFileType::Head description and the data encoded
as 'mimeType'
*/
UInt64 ImageFileType::store(const ImagePtr &image, const char *mimeType,
                            UChar8 *buffer, Int32 memSize)
{
  ImageFileType   *type = ImageFileHandler::the().getFileType(mimeType);
  
  return type ? type->store(image, buffer, memSize) : 0;
}
UInt64 ImageFileHandlerBase::store(Image  const *pImage, 
                                   Char8  const *mimeType,
                                   UChar8       *buffer, 
                                   Int32         memSize )
{
    ImageFileType   *type;
    
    type = mimeType ? getFileType(mimeType) : getDefaultType();
    
    return type->store(pImage, buffer, memSize);
}
UChar8 *ImageFileHandlerBase::store(Image  const *pImage, 
                                    UInt64       &memSize,
                                    Char8  const *mimeType)
{
    ImageFileType   *type = 0;
    UChar8          *mem = 0;

    type    = mimeType ? getFileType(mimeType) : getDefaultType();
    memSize = type->maxBufferSize(pImage);

    if(memSize)
    {
        mem     = new UChar8[size_t(memSize)];

        memSize = type->store(pImage, mem, Int32(memSize));
    }
    else
    {
        FFATAL(("Can not store the image as %s\n", type->getMimeType()));
    }

    return mem;
}