IC Imaging Control C++

saveToFileJPEG Method

saveToFileJPEG Method

This function saves the contents of an image buffer to a JPEG file.
Syntax:
Error saveToFileJPEG( const IFrame& buf, const std::string& filename, int quality = 75 );
Error saveToFileJPEG( const IFrame& buf, const std::wstring& filename, int quality = 75 );
Error saveToFileJPEG( const IFrame& buf, const wchar_t* pFilename, int quality = 75 );

Parameter Description
buf

The buffer that is to be saved.

filename

Specifies the filename of the JPEG file.

pFilename

Specifies the filename of the JPEG file.

quality

Specifies the quality of the JPEG file. This value must be within the range [0,100], with 100 being the highest quality.

Return value:

This method returns an error object. If successful, it is set to eNOERROR. If the conversion fails, eINVALID_PARAM_VAL is returned.

Remarks:

This method saves the contents of the passed IFrame into a JPEG file with the given quality. The contents of the IFrame are internally converted into JPEG format. This conversion may take a while.

Information:

Namespace: DShowLib
Introduced in version 2.0

Sample:

The following sample shows how to snap an image and save it to a JPEG file.

if( m_Grabber.isLive())
{
    // This cast is only valid, if we have previously assigned a FrameHandlerSink to the grabber.
    tFrameHandlerSinkPtr pSink = static_smart_ptr_cast<FrameHandlerSink>( m_Grabber.getSinkTypePtr() );
    Error err = pSink->snapImages( 1 );
    if( !err.isError() )
    {
        DShowLib::saveToFileJPEG( *pSink->getLastAcqMemBuffer(), "Testimage.jpg", 90 );
    }
}

See also: IFrame, MemBuffer, saveToFileBMP, saveToFileJPEG

<< Functions

Get in touch with us


About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, frame grabbers and video converters for production automation, quality assurance, logistics, medicine, science and security.

Our comprehensive range of cameras with USB 3.1, USB 3.0, USB 2.0, GigE interfaces and other innovative machine vision products are renowned for their high quality and ability to meet the performance requirements of demanding applications.

Automated Imaging Association ISO 9001:2015 certified

Contact us