jas_init.c 5.9 KB

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