2011-05-07 00:40:09 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2011 John-Mark Bell <jmb@netsurf-browser.org>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-09-05 03:50:14 +04:00
|
|
|
#include <assert.h>
|
2011-08-28 18:29:15 +04:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "utils/errors.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#include "image/image.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
#include "image/bmp.h"
|
|
|
|
#include "image/gif.h"
|
|
|
|
#include "image/ico.h"
|
|
|
|
#include "image/jpeg.h"
|
|
|
|
#include "image/mng.h"
|
|
|
|
#include "image/nssprite.h"
|
|
|
|
#include "image/png.h"
|
|
|
|
#include "image/rsvg.h"
|
|
|
|
#include "image/svg.h"
|
|
|
|
#include "image/webp.h"
|
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
/**
|
|
|
|
* Initialise image content handlers
|
|
|
|
*
|
|
|
|
* \return NSERROR_OK on success, appropriate error otherwise.
|
|
|
|
*/
|
|
|
|
nserror image_init(void)
|
|
|
|
{
|
|
|
|
nserror error;
|
2011-09-05 03:50:14 +04:00
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#ifdef WITH_BMP
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nsbmp_init();
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#ifdef WITH_GIF
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nsgif_init();
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#ifdef WITH_BMP
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nsico_init();
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#ifdef WITH_JPEG
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nsjpeg_init();
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#ifdef WITH_MNG
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nsmng_init();
|
2011-08-27 12:43:51 +04:00
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
error = nsjpng_init();
|
2011-05-07 00:40:09 +04:00
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_PNG
|
|
|
|
/* Prefer libpng over libmng for pngs by registering later */
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nspng_init();
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#ifdef WITH_NSSPRITE
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nssprite_init();
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif
|
2011-05-07 00:40:09 +04:00
|
|
|
|
|
|
|
/* Prefer rsvg over libsvgtiny for svgs */
|
2011-08-28 18:29:15 +04:00
|
|
|
#ifdef WITH_NS_SVG
|
2011-05-07 00:40:09 +04:00
|
|
|
error = svg_init();
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_RSVG
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nsrsvg_init();
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#ifdef WITH_WEBP
|
2011-05-07 00:40:09 +04:00
|
|
|
error = webp_init();
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
return error;
|
2011-08-28 18:29:15 +04:00
|
|
|
#endif /* WITH_WEBP */
|
2011-05-07 00:40:09 +04:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|