Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
717 mikedld 1
;;================================================================================================;;
3503 dunkaist 2
;;//// libimg.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009, (c) dunkaist, 2011-2013 ///////;;
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
3499 dunkaist 33
LIBIMG_FORMAT_XBM	= 13
34
LIBIMG_FORMAT_Z80	= 14
717 mikedld 35
 
3053 dunkaist 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
3036 dunkaist 44
 
3053 dunkaist 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
3036 dunkaist 51
 
2684 dunkaist 52
; error codes
3036 dunkaist 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
3053 dunkaist 59
LIBIMG_ERROR_SCALE		= 7
60
LIBIMG_ERROR_INTER		= 8
3036 dunkaist 61
LIBIMG_ERROR_NOT_INPLEMENTED	= 9
3053 dunkaist 62
LIBIMG_ERROR_INVALID_INPUT      = 10
2684 dunkaist 63
 
64
; encode flags (byte 0x02 of _common option)
3036 dunkaist 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
2684 dunkaist 69
 
3036 dunkaist 70
; convert flags
3055 dunkaist 71
; TBD
3036 dunkaist 72
 
717 mikedld 73
struct FormatsTableEntry
2684 dunkaist 74
  Format_id	dd ?
75
  Is		dd ?
76
  Decode	dd ?
77
  Encode	dd ?
78
  Capabilities	dd ?
717 mikedld 79
ends
80
 
81
struct Image
3499 dunkaist 82
  Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0]	; ignored so far
717 mikedld 83
  Width    dd ?
84
  Height   dd ?
1593 dunkaist 85
  Next     dd ?
717 mikedld 86
  Previous dd ?
999 diamond 87
  Type     dd ? ; one of Image.bppN
1593 dunkaist 88
  Data     dd ?
3499 dunkaist 89
  Palette  dd ? ; used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i
717 mikedld 90
  Extended dd ?
1079 diamond 91
  Flags    dd ? ; bitfield
92
  Delay    dd ? ; used iff Image.IsAnimated is set in Flags
717 mikedld 93
ends
94
 
1079 diamond 95
; values for Image.Type
96
; must be consecutive to allow fast switch on Image.Type in support functions
2733 dunkaist 97
Image.bpp8i = 1  ; indexed
999 diamond 98
Image.bpp24 = 2
99
Image.bpp32 = 3
1079 diamond 100
Image.bpp15 = 4
101
Image.bpp16 = 5
1593 dunkaist 102
Image.bpp1  = 6
2733 dunkaist 103
Image.bpp8g = 7  ; grayscale
3503 dunkaist 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
999 diamond 107
 
1079 diamond 108
; bits in Image.Flags
109
Image.IsAnimated = 1
110
 
1102 diamond 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
 
1593 dunkaist 116
FLIP_VERTICAL   = 0x01
717 mikedld 117
FLIP_HORIZONTAL = 0x02
1593 dunkaist 118
FLIP_BOTH   = FLIP_VERTICAL or FLIP_HORIZONTAL
783 mikedld 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