Subversion Repositories Kolibri OS

Rev

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