Subversion Repositories Kolibri OS

Rev

Rev 2733 | Rev 3053 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;================================================================================================;;
  2. ;;//// libimg.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009, (c) dunkaist, 2011-2012 ///////;;
  3. ;;================================================================================================;;
  4. ;;                                                                                                ;;
  5. ;; This file is part of Common development libraries (Libs-Dev).                                  ;;
  6. ;;                                                                                                ;;
  7. ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
  8. ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
  9. ;; of the License, or (at your option) any later version.                                         ;;
  10. ;;                                                                                                ;;
  11. ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without  ;;
  12. ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  ;;
  13. ;; Lesser General Public License for more details.                                                ;;
  14. ;;                                                                                                ;;
  15. ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev.  ;;
  16. ;; If not, see <http://www.gnu.org/licenses/>.                                                    ;;
  17. ;;                                                                                                ;;
  18. ;;================================================================================================;;
  19.  
  20. ; list of format id's
  21. LIBIMG_FORMAT_ID_BMP    = 1
  22. LIBIMG_FORMAT_ID_ICO    = 2
  23. LIBIMG_FORMAT_ID_CUR    = 3
  24. LIBIMG_FORMAT_ID_GIF    = 4
  25. LIBIMG_FORMAT_ID_PNG    = 5
  26. LIBIMG_FORMAT_ID_JPEG   = 6
  27. LIBIMG_FORMAT_ID_TGA    = 7
  28. LIBIMG_FORMAT_ID_PCX    = 8
  29. LIBIMG_FORMAT_ID_XCF    = 9
  30. LIBIMG_FORMAT_ID_TIFF   = 10
  31. LIBIMG_FORMAT_ID_PNM    = 11
  32. LIBIMG_FORMAT_ID_WBMP   = 12
  33. LIBIMG_FORMAT_ID_Z80    = 13
  34.  
  35. ; scale type
  36. LIBIMG_SCALE_TYPE_STRETCH       = 0
  37. LIBIMG_SCALE_TYPE_FIT_RECT      = 1
  38. LIBIMG_SCALE_TYPE_FIT_WIDTH     = 2
  39. LIBIMG_SCALE_TYPE_FIT_HEIGHT    = 3
  40. LIBIMG_SCALE_TYPE_FIT_MAX       = 4
  41. ;LIBIMG_SCALE_TYPE_TILE         = 5
  42.  
  43. ; scale algorithm
  44. ;LIBIMG_SCALE_ALG_DEFAULT       = 0
  45. LIBIMG_SCALE_ALG_INTEGER        = 1
  46. LIBIMG_SCALE_ALG_BILINEAR       = 2
  47. ;LIBIMG_SCALE_ALG_BICUBIC       = 3
  48. ;LIBIMG_SCALE_ALG_LANCZOS       = 4
  49.  
  50. ; error codes
  51. LIBIMG_ERROR_OUT_OF_MEMORY      = 1
  52. LIBIMG_ERROR_FORMAT             = 2
  53. LIBIMG_ERROR_CONDITIONS         = 3
  54. LIBIMG_ERROR_BIT_DEPTH          = 4
  55. LIBIMG_ERROR_ENCODER            = 5
  56. LIBIMG_ERROR_SRC_TYPE           = 6
  57. LIBIMG_ERROR_SCALE_TYPE         = 7
  58. LIBIMG_ERROR_SCALE_ALG          = 8
  59. LIBIMG_ERROR_NOT_INPLEMENTED    = 9
  60.  
  61. ; encode flags (byte 0x02 of _common option)
  62. LIBIMG_ENCODE_STRICT_SPECIFIC   = 0x01
  63. LIBIMG_ENCODE_STRICT_BIT_DEPTH  = 0x02
  64. LIBIMG_ENCODE_DELETE_ALPHA      = 0x08
  65. LIBIMG_ENCODE_FLUSH_ALPHA       = 0x10
  66.  
  67. ; convert flags
  68. LIBIMG_CONVERT_IN_PLACE         = 0x01  ; do not create new image, store result in _src
  69.  
  70. struct FormatsTableEntry
  71.   Format_id     dd ?
  72.   Is            dd ?
  73.   Decode        dd ?
  74.   Encode        dd ?
  75.   Capabilities  dd ?
  76. ends
  77.  
  78. struct Image
  79.   Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0]
  80.   Width    dd ?
  81.   Height   dd ?
  82.   Next     dd ?
  83.   Previous dd ?
  84.   Type     dd ? ; one of Image.bppN
  85.   Data     dd ?
  86.   Palette  dd ? ; used iff Type eq Image.bpp8 or Image.bpp1
  87.   Extended dd ?
  88.   Flags    dd ? ; bitfield
  89.   Delay    dd ? ; used iff Image.IsAnimated is set in Flags
  90. ends
  91.  
  92. ; values for Image.Type
  93. ; must be consecutive to allow fast switch on Image.Type in support functions
  94. Image.bpp8i = 1  ; indexed
  95. Image.bpp24 = 2
  96. Image.bpp32 = 3
  97. Image.bpp15 = 4
  98. Image.bpp16 = 5
  99. Image.bpp1  = 6
  100. Image.bpp8g = 7  ; grayscale
  101. Image.bpp8a = 8  ; grayscale with alpha channel; application layer only!!! kernel doesn't handle this image type, libimg can only create and destroy such images
  102. ;Image.bpp4  = 9
  103. ;Image.bpp2  = 10
  104.  
  105. ; bits in Image.Flags
  106. Image.IsAnimated = 1
  107.  
  108. struct ImageDecodeOptions
  109.   UsedSize        dd ? ; if >=8, the field BackgroundColor is valid, and so on
  110.   BackgroundColor dd ? ; used for transparent images as background
  111. ends
  112.  
  113. FLIP_VERTICAL   = 0x01
  114. FLIP_HORIZONTAL = 0x02
  115. FLIP_BOTH   = FLIP_VERTICAL or FLIP_HORIZONTAL
  116.  
  117. ROTATE_90_CW   = 0x01
  118. ROTATE_180     = 0x02
  119. ROTATE_270_CW  = 0x03
  120. ROTATE_90_CCW  = ROTATE_270_CW
  121. ROTATE_270_CCW = ROTATE_90_CW
  122.