source: libcaca/trunk/test/hsv.c @ 811

Last change on this file since 811 was 811, checked in by Sam Hocevar, 14 years ago
  • Renamed caca_t into caca_display_t.
  • Renamed canvas handle variables from "c" to "cv". Eh ouais mon gros.
  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1/*
2 *  hsv           libcaca HSV rendering test program
3 *  Copyright (c) 2003 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: hsv.c 811 2006-04-18 15:11:25Z sam $
7 *
8 *  This program is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#include "config.h"
15
16#if defined(HAVE_INTTYPES_H)
17#   include <inttypes.h>
18#else
19typedef unsigned char uint8_t;
20typedef unsigned short uint16_t;
21typedef unsigned int uint32_t;
22#endif
23
24#include "cucul.h"
25#include "caca.h"
26
27uint32_t buffer[256*256];
28
29int main(void)
30{
31    caca_event_t ev;
32    cucul_canvas_t *cv;
33    caca_display_t *dp;
34
35    cucul_dither_t *dither;
36    int x, y;
37
38    cv = cucul_create(0, 0);
39    dp = caca_attach(cv);
40
41    for(y = 0; y < 256; y++)
42        for(x = 0; x < 256; x++)
43    {
44        buffer[y * 256 + x] = ((y * x / 256) << 16) | ((y * x / 256) << 8) | (x<< 0);
45    }
46
47    dither = cucul_create_dither(32, 256, 256, 4 * 256,
48                                 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
49    cucul_dither_bitmap(cv, 0, 0,
50                        cucul_get_width(cv) - 1, cucul_get_height(cv) - 1,
51                        dither, buffer);
52    cucul_free_dither(dither);
53
54    caca_display(dp);
55
56    caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
57
58    caca_detach(dp);
59    cucul_free(cv);
60
61    return 0;
62}
63
Note: See TracBrowser for help on using the repository browser.