You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.2 KiB

  1. /*
  2. * libcucul Canvas for ultrafast compositing of Unicode letters
  3. * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Do What The Fuck You Want To
  8. * Public License, Version 2, as published by Sam Hocevar. See
  9. * http://sam.zoy.org/wtfpl/COPYING for more details.
  10. */
  11. /** \file colour.c
  12. * \version \$Id$
  13. * \author Sam Hocevar <sam@zoy.org>
  14. * \brief Colour handling
  15. *
  16. * This file contains functions for converting colour values between
  17. * various colourspaces.
  18. */
  19. #include "config.h"
  20. #include "cucul.h"
  21. #include "cucul_internals.h"
  22. /* FIXME: could this be inlined? */
  23. uint8_t _cucul_argb32_to_ansi8(uint32_t c)
  24. {
  25. /* FIXME: we need nearest colour handling for non-ANSI */
  26. return (c & 0x0000000f) | ((c & 0x000f0000) >> 12);
  27. }
  28. uint8_t _cucul_argb32_to_ansi4fg(uint32_t c)
  29. {
  30. /* FIXME: we need nearest colour handling for non-ANSI */
  31. return c & 0x0000000f;
  32. }
  33. uint8_t _cucul_argb32_to_ansi4bg(uint32_t c)
  34. {
  35. /* FIXME: we need nearest colour handling for non-ANSI */
  36. return (c & 0x000f0000) >> 16;
  37. }