KSquirrel: development
Author: Baryshev Dmitry/Krasu

When SQ_LibraryHandler loaded all found libraries, KSquirrel obtains the ability to decode any supported image format. Here is a sample code to decode some image with library. Error handling is turned off. You can find real examples in source distribution of ksquirrel-libs.

Sample

    	int            i, j, current = 0;
    	fmt_info       finfo;
    	RGBA           *image = NULL, *scan;
    	fmt_codec_base *codeK;

    	TQString file = "/home/krasu/animation1.gif";

    	Determine the library and codec
    	codeK = SQ_LibraryHandler::instance()->libraryForFile(file)->codec;

    	Init: open file, etc.
    	codeK->read_init(file.ascii());

    	while(true)
    	{
    		i = codeK->read_next();

    		Break, if we've decoded all available images in file
    		if(i == SQE_NOTOK)
    			break;

    		Obtain the latest information (current image dimensions, etc.)
    		finfo = codeK->information();

    		realloc memory for new image
    		image = (RGBA *)realloc(image, finfo.image[current].w * finfo.image[current].h * sizeof(RGBA));

    		fill with white color (RGBA(255,255,255,255))
    		memset(image, 255, finfo.image[current].w * finfo.image[current].h * sizeof(RGBA));

    		for(int pass = 0;pass < finfo.image[current].passes;pass++)
    		{
    			codeK->read_next_pass();

    			for(j = 0;j < finfo.image[current].h;j++)
    			{
    				scan = image + j * finfo.image[current].w;
    				codeK->read_scanline(scan);
    			}
    		}

    		Do something with decoded image here.
    		...

    		current++;
    	}

    	codeK->read_close();

    	free(image);