jpeg2000.bmx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ' Copyright (c) 2023 Bruce A Henderson
  2. '
  3. ' Redistribution and use in source and binary forms, with or without
  4. ' modification, are permitted provided that the following conditions
  5. ' are met:
  6. ' 1. Redistributions of source code must retain the above copyright
  7. ' notice, this list of conditions and the following disclaimer.
  8. ' 2. Redistributions in binary form must reproduce the above copyright
  9. ' notice, this list of conditions and the following disclaimer in the
  10. ' documentation and/or other materials provided with the distribution.
  11. '
  12. ' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
  13. ' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14. ' IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  15. ' ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  16. ' LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  17. ' CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  18. ' SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  19. ' INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  20. ' CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  21. ' ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  22. ' POSSIBILITY OF SUCH DAMAGE.
  23. '
  24. SuperStrict
  25. Rem
  26. bbdoc: Graphics/JPEG 2000 loader
  27. about:
  28. The JPEG2000 loader module provides the ability to load JPEG 2000 format #pixmaps.
  29. End Rem
  30. Module Image.JPEG2000
  31. ModuleInfo "Version: 1.00"
  32. ModuleInfo "License: BSD 2-Clause"
  33. ModuleInfo "Copyright: Wrapper - 2023 Bruce A Henderson"
  34. ModuleInfo "History: 1.00 Initial Release"
  35. ?win32
  36. ModuleInfo "CC_OPTS: -DOPJ_STATIC"
  37. ?
  38. Import "common.bmx"
  39. Type TJpeg2000Image
  40. Function Load:TPixmap( stream:TStream )
  41. Return bmx_jpeg2000_load( stream )
  42. End Function
  43. Function _NewPixmap:TPixmap(width:Int, height:Int) { nomangle }
  44. Return TPixmap.Create( width,height,PF_STDFORMAT,4)
  45. End Function
  46. Function _PixmapPixels:Byte Ptr(pix:TPixmap) { nomangle }
  47. Return pix.pixels
  48. End Function
  49. Function _stream_seek:Int(pos:Long, stream:TStream) { nomangle }
  50. Local res:Long = stream.seek(pos)
  51. If res = -1 Then
  52. Return False
  53. Else
  54. Return True
  55. End If
  56. End Function
  57. Function _stream_read:Size_T(buf:Byte Ptr, count:Size_T, stream:TStream) { nomangle }
  58. Local res:Long = stream.Read(buf, count)
  59. If res = -1 Then
  60. Return 0
  61. Else
  62. Return res
  63. End If
  64. End Function
  65. Function _stream_skip:Long(count:Long, stream:TStream) { nomangle }
  66. Return stream.seek(count, SEEK_CUR_)
  67. End Function
  68. Function _stream_size:Size_T(stream:TStream) { nomangle }
  69. Return stream.size()
  70. End Function
  71. End Type
  72. Private
  73. Type TPixmapLoaderJPG2000 Extends TPixmapLoader
  74. Method LoadPixmap:TPixmap( stream:TStream ) Override
  75. Return TJpeg2000Image.Load( stream )
  76. End Method
  77. End Type
  78. New TPixmapLoaderJPG2000
  79. Extern
  80. Function bmx_jpeg2000_load:TPixmap( stream:TStream )
  81. End Extern