Subversion Repositories Kolibri OS

Rev

Rev 3053 | Rev 3499 | 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_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_Z80       = 13
  34.  
  35. ; scale type                    ; corresponding img.scale params
  36. LIBIMG_SCALE_INTEGER    = 1     ; scale factor ; reserved 0
  37. LIBIMG_SCALE_TILE       = 2     ; new width    ; new height
  38. LIBIMG_SCALE_STRETCH    = 3     ; new width    ; new height
  39. LIBIMG_SCALE_FIT_RECT   = 4     ; new width    ; new height
  40. LIBIMG_SCALE_FIT_WIDTH  = 5     ; new width    ; new height
  41. LIBIMG_SCALE_FIT_HEIGHT = 6     ; new width    ; new height
  42. LIBIMG_SCALE_FIT_MAX    = 7     ; new width    ; new height
  43.  
  44. ; interpolation algorithm
  45. LIBIMG_INTER_NONE       = 0     ; use it with LIBIMG_SCALE_INTEGER, LIBIMG_SCALE_TILE, etc
  46. LIBIMG_INTER_BILINEAR   = 1
  47. ;LIBIMG_INTER_BICUBIC   = 2
  48. ;LIBIMG_INTER_LANCZOS   = 3
  49. LIBIMG_INTER_DEFAULT    = LIBIMG_INTER_BILINEAR
  50.  
  51. ; error codes
  52. LIBIMG_ERROR_OUT_OF_MEMORY      = 1
  53. LIBIMG_ERROR_FORMAT             = 2
  54. LIBIMG_ERROR_CONDITIONS         = 3
  55. LIBIMG_ERROR_BIT_DEPTH          = 4
  56. LIBIMG_ERROR_ENCODER            = 5
  57. LIBIMG_ERROR_SRC_TYPE           = 6
  58. LIBIMG_ERROR_SCALE              = 7
  59. LIBIMG_ERROR_INTER              = 8
  60. LIBIMG_ERROR_NOT_INPLEMENTED    = 9
  61. LIBIMG_ERROR_INVALID_INPUT      = 10
  62.  
  63. ; encode flags (byte 0x02 of _common option)
  64. LIBIMG_ENCODE_STRICT_SPECIFIC   = 0x01
  65. LIBIMG_ENCODE_STRICT_BIT_DEPTH  = 0x02
  66. LIBIMG_ENCODE_DELETE_ALPHA      = 0x08
  67. LIBIMG_ENCODE_FLUSH_ALPHA       = 0x10
  68.  
  69. ; convert flags
  70. ; TBD
  71.  
  72. struct FormatsTableEntry
  73.   Format_id     dd ?
  74.   Is            dd ?
  75.   Decode        dd ?
  76.   Encode        dd ?
  77.   Capabilities  dd ?
  78. ends
  79.  
  80. struct Image
  81.   Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0]
  82.   Width    dd ?
  83.   Height   dd ?
  84.   Next     dd ?
  85.   Previous dd ?
  86.   Type     dd ? ; one of Image.bppN
  87.   Data     dd ?
  88.   Palette  dd ? ; used iff Type eq Image.bpp8 or Image.bpp1
  89.   Extended dd ?
  90.   Flags    dd ? ; bitfield
  91.   Delay    dd ? ; used iff Image.IsAnimated is set in Flags
  92. ends
  93.  
  94. ; values for Image.Type
  95. ; must be consecutive to allow fast switch on Image.Type in support functions
  96. Image.bpp8i = 1  ; indexed
  97. Image.bpp24 = 2
  98. Image.bpp32 = 3
  99. Image.bpp15 = 4
  100. Image.bpp16 = 5
  101. Image.bpp1  = 6
  102. Image.bpp8g = 7  ; grayscale
  103. 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
  104. ;Image.bpp4  = 9
  105. ;Image.bpp2  = 10
  106.  
  107. ; bits in Image.Flags
  108. Image.IsAnimated = 1
  109.  
  110. struct ImageDecodeOptions
  111.   UsedSize        dd ? ; if >=8, the field BackgroundColor is valid, and so on
  112.   BackgroundColor dd ? ; used for transparent images as background
  113. ends
  114.  
  115. FLIP_VERTICAL   = 0x01
  116. FLIP_HORIZONTAL = 0x02
  117. FLIP_BOTH   = FLIP_VERTICAL or FLIP_HORIZONTAL
  118.  
  119. ROTATE_90_CW   = 0x01
  120. ROTATE_180     = 0x02
  121. ROTATE_270_CW  = 0x03
  122. ROTATE_90_CCW  = ROTATE_270_CW
  123. ROTATE_270_CCW = ROTATE_90_CW
  124.