Subversion Repositories Kolibri OS

Rev

Rev 3053 | Rev 3499 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
717 mikedld 1
;;================================================================================================;;
3036 dunkaist 2
;;//// libimg.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009, (c) dunkaist, 2011-2012 ///////;;
717 mikedld 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 ;;
999 diamond 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.                                         ;;
717 mikedld 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  ;;
999 diamond 13
;; Lesser General Public License for more details.                                                ;;
717 mikedld 14
;;                                                                                                ;;
999 diamond 15
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev.  ;;
16
;; If not, see .                                                    ;;
717 mikedld 17
;;                                                                                                ;;
18
;;================================================================================================;;
19
 
2684 dunkaist 20
; list of format id's
3053 dunkaist 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
717 mikedld 34
 
3053 dunkaist 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
3036 dunkaist 43
 
3053 dunkaist 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
3036 dunkaist 50
 
2684 dunkaist 51
; error codes
3036 dunkaist 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
3053 dunkaist 58
LIBIMG_ERROR_SCALE		= 7
59
LIBIMG_ERROR_INTER		= 8
3036 dunkaist 60
LIBIMG_ERROR_NOT_INPLEMENTED	= 9
3053 dunkaist 61
LIBIMG_ERROR_INVALID_INPUT      = 10
2684 dunkaist 62
 
63
; encode flags (byte 0x02 of _common option)
3036 dunkaist 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
2684 dunkaist 68
 
3036 dunkaist 69
; convert flags
3055 dunkaist 70
; TBD
3036 dunkaist 71
 
717 mikedld 72
struct FormatsTableEntry
2684 dunkaist 73
  Format_id	dd ?
74
  Is		dd ?
75
  Decode	dd ?
76
  Encode	dd ?
77
  Capabilities	dd ?
717 mikedld 78
ends
79
 
80
struct Image
81
  Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0]
82
  Width    dd ?
83
  Height   dd ?
1593 dunkaist 84
  Next     dd ?
717 mikedld 85
  Previous dd ?
999 diamond 86
  Type     dd ? ; one of Image.bppN
1593 dunkaist 87
  Data     dd ?
1921 dunkaist 88
  Palette  dd ? ; used iff Type eq Image.bpp8 or Image.bpp1
717 mikedld 89
  Extended dd ?
1079 diamond 90
  Flags    dd ? ; bitfield
91
  Delay    dd ? ; used iff Image.IsAnimated is set in Flags
717 mikedld 92
ends
93
 
1079 diamond 94
; values for Image.Type
95
; must be consecutive to allow fast switch on Image.Type in support functions
2733 dunkaist 96
Image.bpp8i = 1  ; indexed
999 diamond 97
Image.bpp24 = 2
98
Image.bpp32 = 3
1079 diamond 99
Image.bpp15 = 4
100
Image.bpp16 = 5
1593 dunkaist 101
Image.bpp1  = 6
2733 dunkaist 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
3036 dunkaist 105
;Image.bpp2  = 10
999 diamond 106
 
1079 diamond 107
; bits in Image.Flags
108
Image.IsAnimated = 1
109
 
1102 diamond 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
 
1593 dunkaist 115
FLIP_VERTICAL   = 0x01
717 mikedld 116
FLIP_HORIZONTAL = 0x02
1593 dunkaist 117
FLIP_BOTH   = FLIP_VERTICAL or FLIP_HORIZONTAL
783 mikedld 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