00001 /* 00002 * File Name: scbcolor.c 00003 */ 00004 00005 /* 00006 * This file is part of liberscribble. 00007 * 00008 * liberscribble is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * liberscribble is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 /** 00023 * Copyright (C) 2008 iRex Technologies B.V. 00024 * All rights reserved. 00025 */ 00026 00027 00028 //---------------------------------------------------------------------------- 00029 // Include Files 00030 //---------------------------------------------------------------------------- 00031 00032 // system include files, between < > 00033 #include <stdio.h> 00034 00035 // ereader include files, between < > 00036 00037 // local include files, between " " 00038 #include "scbcolor.h" 00039 #include "scblog.h" 00040 #include "scbtype.h" 00041 #include "scbconfig.h" 00042 00043 00044 //---------------------------------------------------------------------------- 00045 // Type Declarations 00046 //---------------------------------------------------------------------------- 00047 00048 00049 //---------------------------------------------------------------------------- 00050 // Global Constants 00051 //---------------------------------------------------------------------------- 00052 00053 00054 //---------------------------------------------------------------------------- 00055 // Static Variables 00056 //---------------------------------------------------------------------------- 00057 00058 00059 //============================================================================ 00060 // Local Function Definitions 00061 //============================================================================ 00062 00063 00064 //============================================================================ 00065 // Functions Implementation 00066 //============================================================================ 00067 00068 void trace(const char *arg, ...) 00069 { 00070 // TODO: replace this function with macro 00071 printf("%s\n", arg); 00072 } 00073 00074 00075 void erscribble_color_set_white(ScbColorPtr ptr) 00076 { 00077 if (NULL == ptr) return; 00078 ptr->red = 0xff; 00079 ptr->green = 0xff; 00080 ptr->blue = 0xff; 00081 ptr->pixel = 0xffff; 00082 } 00083 00084 00085 void erscribble_color_set_black(ScbColorPtr ptr) 00086 { 00087 if (NULL == ptr) return; 00088 ptr->red = 0; 00089 ptr->green = 0; 00090 ptr->blue = 0; 00091 ptr->pixel = 0; 00092 } 00093 00094 00095 void erscribble_color_set_light_gray(ScbColorPtr ptr) 00096 { 00097 if (NULL == ptr) return; 00098 ptr->red = 0xaa; 00099 ptr->green = 0xaa; 00100 ptr->blue = 0xaa; 00101 ptr->pixel = 0xaaaa; 00102 } 00103 00104 00105 void erscribble_color_set_dark_gray(ScbColorPtr ptr) 00106 { 00107 if (NULL == ptr) return; 00108 ptr->red = 0x55; 00109 ptr->green = 0x55; 00110 ptr->blue = 0x55; 00111 ptr->pixel = 0x5555; 00112 } 00113 00114 00115 ScbDevColor erscribble_color_to_dev_color(ScbColorPtr ptr) 00116 { 00117 if (NULL == ptr) return ERSCRIBBLE_DEV_COLOR_UNKNOWN; 00118 if (0 == ptr->red && 0 == ptr->green && 0 == ptr->blue) 00119 { 00120 return ERSCRIBBLE_DEV_COLOR_BLACK; 00121 } 00122 else if (0xff == ptr->red && 0xff == ptr->green && 0xff == ptr->blue) 00123 { 00124 return ERSCRIBBLE_DEV_COLOR_WHITE; 00125 } 00126 else if (0xaa == ptr->red && 0xaa == ptr->green && 0xaa == ptr->blue) 00127 { 00128 return ERSCRIBBLE_DEV_COLOR_LIGHT_GRAY; 00129 } 00130 else if (0x55 == ptr->red && 0x55 == ptr->green && 0x55 == ptr->blue) 00131 { 00132 return ERSCRIBBLE_DEV_COLOR_DARK_GRAY; 00133 } 00134 return ERSCRIBBLE_DEV_COLOR_UNKNOWN; 00135 } 00136 00137 00138 void erscribble_dev_color_to_color(ScbColorPtr ptr, const ScbDevColor color) 00139 { 00140 if (NULL == ptr) return; 00141 switch(color) 00142 { 00143 case ERSCRIBBLE_DEV_COLOR_WHITE : 00144 00145 erscribble_color_set_white(ptr); 00146 00147 break; 00148 case ERSCRIBBLE_DEV_COLOR_LIGHT_GRAY : 00149 00150 erscribble_color_set_light_gray(ptr); 00151 00152 break; 00153 case ERSCRIBBLE_DEV_COLOR_DARK_GRAY : 00154 00155 erscribble_color_set_dark_gray(ptr); 00156 00157 break; 00158 default: 00159 00160 erscribble_color_set_black(ptr); 00161 00162 break; 00163 } 00164 }