Click here to Skip to main content
15,880,854 members
Articles / Desktop Programming / MFC

ImageStone - A Powerful C++ Class Library for Image Manipulation

Rate me:
Please Sign up or sign in to vote.
4.81/5 (250 votes)
6 Dec 2011Zlib3 min read 117.1K   51.5K   405  
An article on a library for image manipulation
#ifdef _MSC_VER
    #if _MSC_VER >= 1400
        #define _CRT_SECURE_NO_DEPRECATE
    #endif
#endif

#include <stdio.h>
#define PCL_3RD_LIBRARY_USE_FREEIMAGE
#define FREEIMAGE_LIB
#include "../../../ImageStone.h"

//================================================================================
int main (int argc, char* argv[])
{
    FCObjImage::SetImageHandleFactory (new FCImageHandleFactory_FreeImage) ;

	const char* szTestFile = "test.gif" ; // image to load

    // not found
    FILE   * pf = fopen (szTestFile, "rb") ;
    if (pf)
        fclose(pf) ;
    if (!pf)
    {
        printf ("can't load %s, please put a gif file named %s in same folder of exe file.\n", szTestFile, szTestFile) ;
        return 0 ;
    }

    FCObjMultiFrame   img ;
    if (!img.Load (szTestFile))
    {
        printf ("can't load %s, please put %s in same folder.\n", szTestFile, szTestFile) ;
        return 0 ;
    }

    printf ("%s loade success.\n\n", szTestFile) ;

    for (int i=0 ; i < img.GetFrameCount() ; i++)
    {
        std::string   s = FCOXOHelper::X2A(i) + ".jpg" ;
        img.GetFrame(i)->ConvertTo24Bit() ;
        img.GetFrame(i)->Save (s.c_str(), 90) ; // quality == 90
        printf ("page-%d save as %s\n", i, s.c_str()) ;
    }
    printf ("\n\n") ;

    return 0 ;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The zlib/libpng License


Written By
Team Leader PhoXo
China China
graduate from University of Science and Technology of China at 2002.

Now I work at www.phoxo.com.

Comments and Discussions