Subversion Repositories Kolibri OS

Rev

Rev 6807 | 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-2013 ///////;;
  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_BMP       = 1
  22. LIBIMG_FORMAT_ICO       = 2
  23. LIBIMG_FORMAT_CUR       = 3
  24. LIBIMG_FORMAT_GIF       = 4
  25. LIBIMG_FORMAT_PNG       = 5
  26. LIBIMG_FORMAT_JPEG      = 6
  27. LIBIMG_FORMAT_TGA       = 7
  28. LIBIMG_FORMAT_PCX       = 8
  29. LIBIMG_FORMAT_XCF       = 9
  30. LIBIMG_FORMAT_TIFF      = 10
  31. LIBIMG_FORMAT_PNM       = 11
  32. LIBIMG_FORMAT_WBMP      = 12
  33. LIBIMG_FORMAT_XBM       = 13
  34. LIBIMG_FORMAT_Z80       = 14
  35.  
  36. ; scale type                    ; corresponding img.scale params
  37. LIBIMG_SCALE_NONE       = 0     ; do not scale
  38. LIBIMG_SCALE_INTEGER    = 1     ; scale factor ; reserved 0
  39. LIBIMG_SCALE_TILE       = 2     ; new width    ; new height
  40. LIBIMG_SCALE_STRETCH    = 3     ; new width    ; new height
  41. LIBIMG_SCALE_FIT_BOTH   = LIBIMG_SCALE_STRETCH
  42. LIBIMG_SCALE_FIT_MIN    = 4     ; new width    ; new height
  43. LIBIMG_SCALE_FIT_RECT   = LIBIMG_SCALE_FIT_MIN
  44. LIBIMG_SCALE_FIT_WIDTH  = 5     ; new width    ; new height
  45. LIBIMG_SCALE_FIT_HEIGHT = 6     ; new width    ; new height
  46. LIBIMG_SCALE_FIT_MAX    = 7     ; new width    ; new height
  47.  
  48. ; interpolation algorithm
  49. LIBIMG_INTER_NONE       = 0     ; use it with LIBIMG_SCALE_INTEGER, LIBIMG_SCALE_TILE, etc
  50. LIBIMG_INTER_BILINEAR   = 1
  51. ;LIBIMG_INTER_BICUBIC   = 2
  52. ;LIBIMG_INTER_LANCZOS   = 3
  53. LIBIMG_INTER_DEFAULT    = LIBIMG_INTER_BILINEAR
  54.  
  55. ; error codes
  56. LIBIMG_ERROR_OUT_OF_MEMORY      = 1
  57. LIBIMG_ERROR_FORMAT             = 2
  58. LIBIMG_ERROR_CONDITIONS         = 3
  59. LIBIMG_ERROR_BIT_DEPTH          = 4
  60. LIBIMG_ERROR_ENCODER            = 5
  61. LIBIMG_ERROR_SRC_TYPE           = 6
  62. LIBIMG_ERROR_SCALE              = 7
  63. LIBIMG_ERROR_INTER              = 8
  64. LIBIMG_ERROR_NOT_INPLEMENTED    = 9
  65. LIBIMG_ERROR_INVALID_INPUT      = 10
  66.  
  67. ; encode flags (byte 0x02 of _common option)
  68. ;LIBIMG_ENCODE_STRICT_SPECIFIC = 0x01
  69. LIBIMG_ENCODE_STRICT_BIT_DEPTH = 0x02
  70. ;LIBIMG_ENCODE_DELETE_ALPHA    = 0x08
  71. ;LIBIMG_ENCODE_FLUSH_ALPHA     = 0x10
  72.  
  73. ; convert flags
  74. ; none so far
  75.  
  76. struct FormatsTableEntry
  77.   Format_id     dd ?
  78.   Is            dd ?
  79.   Decode        dd ?
  80.   Encode        dd ?
  81.   Capabilities  dd ?
  82. ends
  83.  
  84. struct Image
  85.   Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0]        ; ignored so far
  86.   Width    dd ?
  87.   Height   dd ?
  88.   Next     dd ?
  89.   Previous dd ?
  90.   Type     dd ? ; one of Image.bppN
  91.   Data     dd ?
  92.   Palette  dd ? ; used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i
  93.   Extended dd ?
  94.   Flags    dd ? ; bitfield
  95.   Delay    dd ? ; used iff Image.IsAnimated is set in Flags
  96. ends
  97.  
  98. ; values for Image.Type
  99. ; must be consecutive to allow fast switch on Image.Type in support functions
  100. Image.bpp8i = 1  ; indexed
  101. Image.bpp24 = 2
  102. Image.bpp32 = 3
  103. Image.bpp15 = 4
  104. Image.bpp16 = 5
  105. Image.bpp1  = 6
  106. Image.bpp8g = 7  ; grayscale
  107. Image.bpp2i = 8
  108. Image.bpp4i = 9
  109. Image.bpp8a = 10  ; grayscale with alpha channel; application layer only!!! kernel doesn't handle this image type, libimg can only create and destroy such images
  110.  
  111. ; bits in Image.Flags
  112. Image.IsAnimated = 1
  113.  
  114. struct ImageDecodeOptions
  115.   UsedSize        dd ? ; if >=8, the field BackgroundColor is valid, and so on
  116.   BackgroundColor dd ? ; used for transparent images as background
  117. ends
  118.  
  119. FLIP_VERTICAL   = 0x01
  120. FLIP_HORIZONTAL = 0x02
  121. FLIP_BOTH   = FLIP_VERTICAL or FLIP_HORIZONTAL
  122.  
  123. ROTATE_90_CW   = 0x01
  124. ROTATE_180     = 0x02
  125. ROTATE_270_CW  = 0x03
  126. ROTATE_90_CCW  = ROTATE_270_CW
  127. ROTATE_270_CCW = ROTATE_90_CW
  128.