1 /* -----------------------------------------------------------------------------
2  *
3  * Copyright (c) 2007-2017 Alexis Naveros.
4  * Portions developed under contract to the SURVICE Engineering Company.
5  *
6  * This software is provided 'as-is', without any express or implied
7  * warranty. In no event will the authors be held liable for any damages
8  * arising from the use of this software.
9  *
10  * Permission is granted to anyone to use this software for any purpose,
11  * including commercial applications, and to alter it and redistribute it
12  * freely, subject to the following restrictions:
13  *
14  * 1. The origin of this software must not be misrepresented; you must not
15  * claim that you wrote the original software. If you use this software
16  * in a product, an acknowledgment in the product documentation would be
17  * appreciated but is not required.
18  * 2. Altered source versions must be plainly marked as such, and must not be
19  * misrepresented as being the original software.
20  * 3. This notice may not be removed or altered from any source distribution.
21  *
22  * -----------------------------------------------------------------------------
23  */
24 
25 #ifndef IMG_H
26 #define IMG_H
27 
28 
29 typedef struct
30 {
31   int width;
32   int height;
33   int type;
34   int bytesperpixel;
35   int bytesperline;
36 } imgFormat;
37 
38 enum
39 {
40   IMG_FORMAT_TYPE_ANY,
41   IMG_FORMAT_TYPE_RGB24,
42   IMG_FORMAT_TYPE_BGR24,
43   IMG_FORMAT_TYPE_RGBX32,
44   IMG_FORMAT_TYPE_BGRX32,
45   IMG_FORMAT_TYPE_RGBA32,
46   IMG_FORMAT_TYPE_BGRA32,
47   IMG_FORMAT_TYPE_GRAYSCALE,
48   IMG_FORMAT_TYPE_GRAYALPHA
49 };
50 
51 typedef struct
52 {
53   imgFormat format;
54   void *data;
55 } imgImage;
56 
57 
58 ////
59 
60 
61 void imgCopyRect( imgImage *image, int dstx, int dsty, int srcx, int srcy, int sizex, int sizey );
62 
63 void (*imgBlendGetFunction( imgImage *dstimage, imgImage *srcimage ))( imgImage *dstimage, int dstx, int dsty, imgImage *srcimage );
64 int imgBlendImage( imgImage *dstimage, int dstx, int dsty, imgImage *srcimage );
65 
66 void imgAllocCopy( imgImage *dst, imgImage *src );
67 void imgAllocCopyExtendBorder( imgImage *dstimage, imgImage *srcimage, int extendsize );
68 void imgAllocExtractChannel( imgImage *dst, imgImage *src, int channelindex );
69 void imgAllocExtractChannelExtendBorder( imgImage *dstimage, imgImage *srcimage, int channelindex, int extendsize );
70 void imgAllocCopyChannelToAlpha( imgImage *dstimage, imgImage *srcimage, int channelindex, unsigned char r, unsigned char g, unsigned char b );
71 void imgAllocAdjustBrightnessContrast( imgImage *dstimage, imgImage *srcimage, float brightness, float contrast );
72 
73 void imgFree( imgImage *image );
74 
75 
76 #endif
77 
78