1/* 2 * Copyright (c) 2001-2002 Michael David Adams. 3 * All rights reserved. 4 */ 5 6/* __START_OF_JASPER_LICENSE__ 7 * 8 * JasPer License Version 2.0 9 * 10 * Copyright (c) 2001-2006 Michael David Adams 11 * Copyright (c) 1999-2000 Image Power, Inc. 12 * Copyright (c) 1999-2000 The University of British Columbia 13 * 14 * All rights reserved. 15 * 16 * Permission is hereby granted, free of charge, to any person (the 17 * "User") obtaining a copy of this software and associated documentation 18 * files (the "Software"), to deal in the Software without restriction, 19 * including without limitation the rights to use, copy, modify, merge, 20 * publish, distribute, and/or sell copies of the Software, and to permit 21 * persons to whom the Software is furnished to do so, subject to the 22 * following conditions: 23 * 24 * 1. The above copyright notices and this permission notice (which 25 * includes the disclaimer below) shall be included in all copies or 26 * substantial portions of the Software. 27 * 28 * 2. The name of a copyright holder shall not be used to endorse or 29 * promote products derived from the Software without specific prior 30 * written permission. 31 * 32 * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS 33 * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER 34 * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 35 * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 36 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 37 * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO 38 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 39 * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 40 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 41 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 42 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE 43 * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE 44 * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY. 45 * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS 46 * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL 47 * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS 48 * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE 49 * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE 50 * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL 51 * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES, 52 * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL 53 * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH 54 * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH, 55 * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH 56 * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY 57 * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES. 58 * 59 * __END_OF_JASPER_LICENSE__ 60 */ 61 62/******************************************************************************\ 63* Includes. 64\******************************************************************************/ 65 66#include "jasper/jas_types.h" 67#include "jasper/jas_image.h" 68#include "jasper/jas_init.h" 69 70/******************************************************************************\ 71* Code. 72\******************************************************************************/ 73 74/* Initialize the image format table. */ 75int jas_init() 76{ 77 jas_image_fmtops_t fmtops; 78 int fmtid; 79 80 fmtid = 0; 81 82#if !defined(EXCLUDE_MIF_SUPPORT) 83 fmtops.decode = mif_decode; 84 fmtops.encode = mif_encode; 85 fmtops.validate = mif_validate; 86 jas_image_addfmt(fmtid, "mif", "mif", "My Image Format (MIF)", &fmtops); 87 ++fmtid; 88#endif 89 90#if !defined(EXCLUDE_PNM_SUPPORT) 91 fmtops.decode = pnm_decode; 92 fmtops.encode = pnm_encode; 93 fmtops.validate = pnm_validate; 94 jas_image_addfmt(fmtid, "pnm", "pnm", "Portable Graymap/Pixmap (PNM)", 95 &fmtops); 96 jas_image_addfmt(fmtid, "pnm", "pgm", "Portable Graymap/Pixmap (PNM)", 97 &fmtops); 98 jas_image_addfmt(fmtid, "pnm", "ppm", "Portable Graymap/Pixmap (PNM)", 99 &fmtops); 100 ++fmtid; 101#endif 102 103#if !defined(EXCLUDE_BMP_SUPPORT) 104 fmtops.decode = bmp_decode; 105 fmtops.encode = bmp_encode; 106 fmtops.validate = bmp_validate; 107 jas_image_addfmt(fmtid, "bmp", "bmp", "Microsoft Bitmap (BMP)", &fmtops); 108 ++fmtid; 109#endif 110 111#if !defined(EXCLUDE_RAS_SUPPORT) 112 fmtops.decode = ras_decode; 113 fmtops.encode = ras_encode; 114 fmtops.validate = ras_validate; 115 jas_image_addfmt(fmtid, "ras", "ras", "Sun Rasterfile (RAS)", &fmtops); 116 ++fmtid; 117#endif 118 119#if !defined(EXCLUDE_JP2_SUPPORT) 120 fmtops.decode = jp2_decode; 121 fmtops.encode = jp2_encode; 122 fmtops.validate = jp2_validate; 123 jas_image_addfmt(fmtid, "jp2", "jp2", 124 "JPEG-2000 JP2 File Format Syntax (ISO/IEC 15444-1)", &fmtops); 125 ++fmtid; 126 fmtops.decode = jpc_decode; 127 fmtops.encode = jpc_encode; 128 fmtops.validate = jpc_validate; 129 jas_image_addfmt(fmtid, "jpc", "jpc", 130 "JPEG-2000 Code Stream Syntax (ISO/IEC 15444-1)", &fmtops); 131 ++fmtid; 132#endif 133 134#if !defined(EXCLUDE_JPG_SUPPORT) 135 fmtops.decode = jpg_decode; 136 fmtops.encode = jpg_encode; 137 fmtops.validate = jpg_validate; 138 jas_image_addfmt(fmtid, "jpg", "jpg", "JPEG (ISO/IEC 10918-1)", &fmtops); 139 ++fmtid; 140#endif 141 142#if !defined(EXCLUDE_PGX_SUPPORT) 143 fmtops.decode = pgx_decode; 144 fmtops.encode = pgx_encode; 145 fmtops.validate = pgx_validate; 146 jas_image_addfmt(fmtid, "pgx", "pgx", "JPEG-2000 VM Format (PGX)", &fmtops); 147 ++fmtid; 148#endif 149 150 /* We must not register the JasPer library exit handler until after 151 at least one memory allocation is performed. This is desirable 152 as it ensures that the JasPer exit handler is called before the 153 debug memory allocator exit handler. */ 154 atexit(jas_cleanup); 155 156 return 0; 157} 158 159void jas_cleanup() 160{ 161 jas_image_clearfmts(); 162} 163