1 /** 2 * painter main header 3 * 4 * Copyright 2015-2016 Jay Sorg <jay.sorg@gmail.com> 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #if !defined(__PAINTER_H) 20 #define __PAINTER_H 21 22 #define LIBPAINTER_VERSION_MAJOR 0 23 #define LIBPAINTER_VERSION_MINOR 1 24 #define LIBPAINTER_VERSION_MICRO 0 25 26 #define PT_FORMAT_a8b8g8r8 \ 27 ((32 << 24) | (3 << 16) | (8 << 12) | (8 << 8) | (8 << 4) | 8) 28 #define PT_FORMAT_a8r8g8b8 \ 29 ((32 << 24) | (2 << 16) | (8 << 12) | (8 << 8) | (8 << 4) | 8) 30 #define PT_FORMAT_r5g6b5 \ 31 ((16 << 24) | (2 << 16) | (0 << 12) | (5 << 8) | (6 << 4) | 5) 32 #define PT_FORMAT_a1r5g5b5 \ 33 ((16 << 24) | (2 << 16) | (1 << 12) | (5 << 8) | (5 << 4) | 5) 34 #define PT_FORMAT_r3g3b2 \ 35 ((8 << 24) | (2 << 16) | (0 << 12) | (3 << 8) | (3 << 4) | 2) 36 37 #define PT_FORMAT_c1 \ 38 ((1 << 24) | (4 << 16) | (0 << 12) | (0 << 8) | (0 << 4) | 0) 39 #define PT_FORMAT_c8 \ 40 ((8 << 24) | (4 << 16) | (0 << 12) | (0 << 8) | (0 << 4) | 0) 41 42 struct painter_bitmap 43 { 44 int format; 45 int width; 46 int stride_bytes; 47 int height; 48 char *data; 49 }; 50 51 #define PT_ERROR_NONE 0 52 #define PT_ERROR_OUT_OF_MEM 1 53 #define PT_ERROR_PARAM 2 54 #define PT_ERROR_NOT_IMP 3 55 56 #define PT_PATTERN_MODE_NORMAL 0 57 #define PT_PATTERN_MODE_OPAQUE 1 58 59 #define PT_LINE_FLAGS_NONE 0 60 61 /* reverse Windows X11 */ 62 /* polish */ 63 #define PT_ROP_0 0x00 /* 0 BLACKNESS GXclear */ 64 #define PT_ROP_DSon 0x11 /* DSon NOTSRCERASE GXnor */ 65 #define PT_ROP_DSna 0x22 /* DSna GXandInverted */ 66 #define PT_ROP_Sn 0x33 /* Sn NOTSRCCOPY GXcopyInverted */ 67 #define PT_ROP_SDna 0x44 /* SDna SRCERASE GXandReverse */ 68 #define PT_ROP_Dn 0x55 /* Dn DSTINVERT GXinvert */ 69 #define PT_ROP_DSx 0x66 /* DSx SRCINVERT GXxor */ 70 #define PT_ROP_DSan 0x77 /* DSan GXnand */ 71 #define PT_ROP_DSa 0x88 /* DSa SRCAND GXand */ 72 #define PT_ROP_DSxn 0x99 /* DSxn GXequiv */ 73 #define PT_ROP_D 0xAA /* D GXnoop */ 74 #define PT_ROP_DSno 0xBB /* DSno MERGEPAINT GXorInverted */ 75 #define PT_ROP_S 0xCC /* S SRCCOPY GXcopy */ 76 #define PT_ROP_SDno 0xDD /* SDno GXorReverse */ 77 #define PT_ROP_DSo 0xEE /* DSo GXor */ 78 #define PT_ROP_1 0xFF /* 1 WHITENESS GXset */ 79 80 int 81 painter_create(void **handle); 82 int 83 painter_delete(void *handle); 84 int 85 painter_set_fgcolor(void *handle, int color); 86 int 87 painter_set_bgcolor(void *handle, int color); 88 int 89 painter_set_rop(void *handle, int rop); 90 int 91 painter_set_pattern_mode(void *handle, int mode); 92 int 93 painter_set_pattern_origin(void *handle, int x, int y); 94 int 95 painter_set_clip(void *handle, int x, int y, int cx, int cy); 96 int 97 painter_clear_clip(void *handle); 98 int 99 painter_fill_rect(void *handle, struct painter_bitmap *dst, 100 int x, int y, int cx, int cy); 101 int 102 painter_fill_pattern(void *handle, struct painter_bitmap *dst, 103 struct painter_bitmap *pat, int patx, int paty, 104 int x, int y, int cx, int cy); 105 int 106 painter_copy(void *handle, struct painter_bitmap *dst, 107 int x, int y, int cx, int cy, 108 struct painter_bitmap *src, int srcx, int srcy); 109 int 110 painter_line(void *handle, struct painter_bitmap *dst, 111 int x1, int y1, int x2, int y2, int width, int flags); 112 int 113 painter_get_version(int *major, int *minor, int *micro); 114 115 #endif 116