colourtran 13.3 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
/* Copyright 1996 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/****************************************************************************
 * This source file was written by Acorn Computers Limited. It is part of   *
 * the RISCOS library for writing applications in C for RISC OS. It may be  *
 * used freely in the creation of programs for Archimedes. It should be     *
 * used with Acorn's C Compiler Release 3 or later.                         *
 *                                                                          *
 ***************************************************************************/

/*
 * Title:  colourtran.h
 * Purpose: C interface to the ColourTrans SWIs
 *
 */

#ifndef __colourtran_h
#define __colourtran_h

#ifndef __os_h
#include "os.h"
#endif

#ifndef __wimp_h
#include "wimp.h"
#endif

#ifndef __font_h
#include "font.h"
#endif


/* ----------------------- colourtran_select_table -------------------------
 * Description:   Sets up a translation table in a buffer, given a source
 *                mode and palette, and a destination mode and palette.
 *
 * Parameters:    int source_mode -- source mode
 *                wimp_paletteword *source_palette -- source palette
 *                int dest_mode -- destination mode
 *                wimp_paletteword *dest_palette -- destination palette
 *                void *buffer -- pointer to store for the table.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_select_table (int source_mode,
                                   wimp_paletteword *source_palette,
                                   int dest_mode,
                                   wimp_paletteword *dest_palette,
                                   void *buffer);


/* ---------------------- colourtran_select_GCOLtable ----------------------
 * Description:   Sets up a list of GCOLs in a buffer, given a source
 *                mode and palette, and a destination mode and palette.
 *
 * Parameters:    int source_mode -- source mode
 *                wimp_paletteword *source_palette -- source palette
 *                int dest_mode -- destination mode
 *                wimp_paletteword *dest_palette -- destination palette
 *                void *buffer -- pointer to store for the list of GCOLs.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_select_GCOLtable (int source_mode,
                                       wimp_paletteword *source_palette,
                                       int dest_mode,
                                       wimp_paletteword *dest_palette,
                                       void *buffer);


/* ------------------------- colourtran_returnGCOL -------------------------
 * Description:   Informs caller of the closest GCOL in the current mode
 *                to a given palette entry.
 *
 * Parameters:    wimp_paletteword entry -- the palette entry
 *                int *gcol -- returned GCOL value.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_returnGCOL (wimp_paletteword entry, int *gcol);


/* ------------------------ colourtran_setGCOL -----------------------------
 * Description:   Informs caller of the closest GCOL in the current mode
 *                to a given palette entry, and also sets the GCOL.
 *
 * Parameters:    wimp_paletteword entry -- the palette entry
 *                int fore_back -- set to 0 for foreground,
 *                                 set to 128 for background
 *                int gcol_in -- GCOL action
 *                int *gcol_out -- returned closest GCOL.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_setGCOL (wimp_paletteword entry, int fore_back,
                              int gcol_in, int *gcol_out);


/* ---------------------- colourtran_return_colournumber -------------------
 * Description:   Informs caller of the closeset colour number to a given
 *                palette entry, in the current mode and palette
 *
 * Parameters:    wimp_paletteword entry -- the palette entry
 *                int *col -- returned colour number.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_return_colournumber (wimp_paletteword entry, int *col);


/* --------------------- colourtran_return_GCOLformode ---------------------
 * Description:   Informs caller of the closest GCOL to a given palette
 *                entry, destination mode and destination palette.
 *
 * Parameters:    wimp_paletteword entry -- the palette entry
 *                int dest_mode -- destination mode
 *                wimp_paletteword *dest_palette -- destination palette
 *                int *gcol -- returned closest GCOL.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_return_GCOLformode (wimp_paletteword entry,
                                         int dest_mode,
                                         wimp_paletteword *dest_palette,
                                         int *gcol);


/* ------------------ colourtran_return_colourformode ----------------------
 * Description:   Informs caller of the closest colour number to a given
 *                palette entry, destination mode and destination palette.
 *
 * Parameters:    wimp_paletteword entry -- the palette entry
 *                int dest_mode -- destination mode
 *                wimp_paletteword *dest_palette -- destination palette
 *                int *col -- returned closest colour number.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_return_colourformode (wimp_paletteword entry,
                                           int dest_mode,
                                           wimp_paletteword *dest_palette,
                                           int *col);


/* ----------------------- colourtran_return_OppGCOL -----------------------
 * Description:   Informs caller of the furthest GCOL in the current mode
 *                from a given palette entry.
 *
 * Parameters:    wimp_paletteword entry -- the palette entry
 *                int *gcol -- returned GCOL value.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_return_OppGCOL (wimp_paletteword entry, int *gcol);


/* ------------------------ colourtran_setOppGCOL --------------------------
 * Description:   Informs caller of the furthest GCOL in the current mode
 *                from a given palette entry, and also sets the GCOL.
 *
 * Parameters:    wimp_paletteword entry -- the palette entry
 *                int fore_back -- set to 0 for foreground,
 *                                 set to 128 for background
 *                int gcol_in -- GCOL action
 *                int *gcol_out -- returned furthest GCOL.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_setOppGCOL (wimp_paletteword entry, int fore_back,
                                int gcol_in, int *gcol_out);


/* ---------------------- colourtran_return_Oppcolournumber ----------------
 * Description:   Informs caller of the furthest colour number from a given
 *                palette entry, in the current mode and palette
 *
 * Parameters:    wimp_paletteword -- the palette entry
 *                int *col -- returned colour number.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_return_Oppcolournumber (wimp_paletteword entry,
                                             int *col);


/* --------------------- colourtran_return_OppGCOLformode ------------------
 * Description:   Informs caller of the furthest GCOL from a given palette
 *                entry, destination mode and destination palette.
 *
 * Parameters:    wimp_paletteword entry -- the palette entry
 *                int dest_mode -- destination mode
 *                wimp_paletteword *dest_palette -- destination palette
 *                int *gcol -- returned furthest GCOL.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_return_OppGCOLformode (wimp_paletteword entry,
                                            int dest_mode,
                                            wimp_paletteword *dest_palette,
                                            int *gcol);


/* ------------------ colourtran_return_Oppcolourformode -------------------
 * Description:   Informs caller of the furthest colour number from a given
 *                palette entry, destination mode and destination palette.
 *
 * Parameters:    wimp_paletteword entry -- the palette entry
 *                int dest_mode -- destination mode
 *                wimp_paletteword *dest_palette -- destination palette
 *                int *col -- returned furthest colour number.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_return_Oppcolourformode (wimp_paletteword entry,
                                              int dest_mode,
                                              wimp_paletteword *dest_palette,
                                              int *col);


/* ---------------------- colourtran_GCOL_tocolournumber -------------------
 * Description:   Translates a GCOL to a colournumber (assuming 256-colour
 *                mode).
 *
 * Parameters:    int gcol -- the GCOL
 *                int *col -- returned colour number.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_GCOL_tocolournumber (int gcol, int *col);


/* ----------------- colourtran_colournumbertoGCOL -------------------------
 * Description:   Translates a colour number to a GCOL (assuming 256-colour
 *                mode).
 *
 * Parameters:    int col -- the colour number
 *                int *gcol -- the returned GCOL.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_colournumbertoGCOL (int col, int *gcol);


/* ------------------ colourtran_returnfontcolours -------------------------
 * Description:   Informs caller of font colours to match given colours.
 *
 * Parameters:    font *handle -- the font's handle
 *                wimp_paletteword *backgnd -- background palette entry
 *                wimp_paletteword *foregnd -- foreground palette entry
 *                int *max_offset
 * Returns:       possible error condition.
 * Other Info:    Closest approximations to fore/background colours will be
 *                set, and as many intermediate colours as possible (up to
 *                a maximum of *max_offset). Values are returned through
 *                the parameters.
 *
 */

os_error *colourtran_returnfontcolours (font *handle,
                                        wimp_paletteword *backgnd,
                                        wimp_paletteword *foregnd,
                                        int *max_offset);


/* -------------------- colourtran_setfontcolours --------------------------
 * Description:   Informs caller of font colours to match given colours, and
 *                calls font_setfontcolour() to set them.
 *
 * Parameters:    font *handle -- the font's handle
 *                wimp_paletteword *backgnd -- background palette entry
 *                wimp_paletteword *foregnd -- foreground palette entry
 *                int *max_offset
 * Returns:       possible error condition.
 * Other Info:    Closest approximations to fore/background colours will be
 *                set, and as many intermediate colours as possible (up to
 *                a maximum of *max_offset). Values are returned through
 *                the parameters. Font_setfontcolours() is then called with
 *                these as parameters.
 *
 */
os_error *colourtran_setfontcolours (font *handle,
                                     wimp_paletteword *backgnd,
                                     wimp_paletteword *foregnd,
                                     int *max_offset);


/* ----------------------- colourtran_invalidate_cache ---------------------
 * Description:   To be called when the palette has changed since a call was
 *                last made to a function in this module.
 *
 * Parameters:    void.
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

os_error *colourtran_invalidate_cache (void);


/* ----------------------- colourtran_convert_device_colour ----------------
 * Description:   Convert from a device colour to a standard RGB colour
 *
 * Parameters:    wimp_paletteword device colour
                  wimp_paletteword *rgb colour
 * Returns:       possible error condition.
 * Other Info:    Uses the current calibration to convert from a device
 *                colour to a standard RGB palette entry
 *
 */

os_error *colourtran_convert_device_colour ( wimp_paletteword device,
                                             wimp_paletteword *rgb );

#endif
/* end colourtran.h */