Subversion Repositories Kolibri OS

Rev

Rev 2733 | Rev 3053 | 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
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
717 mikedld 34
 
3036 dunkaist 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
 
2684 dunkaist 50
; error codes
3036 dunkaist 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
2684 dunkaist 60
 
61
; encode flags (byte 0x02 of _common option)
3036 dunkaist 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
2684 dunkaist 66
 
3036 dunkaist 67
; convert flags
68
LIBIMG_CONVERT_IN_PLACE		= 0x01	; do not create new image, store result in _src
69
 
717 mikedld 70
struct FormatsTableEntry
2684 dunkaist 71
  Format_id	dd ?
72
  Is		dd ?
73
  Decode	dd ?
74
  Encode	dd ?
75
  Capabilities	dd ?
717 mikedld 76
ends
77
 
78
struct Image
79
  Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0]
80
  Width    dd ?
81
  Height   dd ?
1593 dunkaist 82
  Next     dd ?
717 mikedld 83
  Previous dd ?
999 diamond 84
  Type     dd ? ; one of Image.bppN
1593 dunkaist 85
  Data     dd ?
1921 dunkaist 86
  Palette  dd ? ; used iff Type eq Image.bpp8 or Image.bpp1
717 mikedld 87
  Extended dd ?
1079 diamond 88
  Flags    dd ? ; bitfield
89
  Delay    dd ? ; used iff Image.IsAnimated is set in Flags
717 mikedld 90
ends
91
 
1079 diamond 92
; values for Image.Type
93
; must be consecutive to allow fast switch on Image.Type in support functions
2733 dunkaist 94
Image.bpp8i = 1  ; indexed
999 diamond 95
Image.bpp24 = 2
96
Image.bpp32 = 3
1079 diamond 97
Image.bpp15 = 4
98
Image.bpp16 = 5
1593 dunkaist 99
Image.bpp1  = 6
2733 dunkaist 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
3036 dunkaist 103
;Image.bpp2  = 10
999 diamond 104
 
1079 diamond 105
; bits in Image.Flags
106
Image.IsAnimated = 1
107
 
1102 diamond 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
 
1593 dunkaist 113
FLIP_VERTICAL   = 0x01
717 mikedld 114
FLIP_HORIZONTAL = 0x02
1593 dunkaist 115
FLIP_BOTH   = FLIP_VERTICAL or FLIP_HORIZONTAL
783 mikedld 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