source: libcaca/trunk/java/org_zoy_caca_Attribute.c @ 4197

Last change on this file since 4197 was 4197, checked in by Sam Hocevar, 13 years ago

Java bindings, courtesy of Adrien Grand <jpountz@dinauz.org>.

File size: 1.6 KB
Line 
1/*
2 *  libcaca       Java bindings for libcaca
3 *  Copyright (c) 2009 Adrien Grand <jpountz@dinauz.org>
4 *
5 *  $Id$
6 *
7 *  This library is free software. It comes without any warranty, to
8 *  the extent permitted by applicable law. You can redistribute it
9 *  and/or modify it under the terms of the Do What The Fuck You Want
10 *  To Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#include "org_zoy_caca_Attribute.h"
15
16#include "caca.h"
17
18
19JNIEXPORT jbyte JNICALL
20Java_org_zoy_caca_Attribute_attributeToAnsi(JNIEnv *env, jclass cls, jint attr)
21{
22  return caca_attr_to_ansi(attr);
23}
24
25JNIEXPORT jbyte JNICALL
26Java_org_zoy_caca_Attribute_attributeToAnsiForeground(JNIEnv *env, jclass cls, jint attr)
27{
28  return caca_attr_to_ansi_fg(attr);
29}
30
31JNIEXPORT jbyte JNICALL
32Java_org_zoy_caca_Attribute_attributeToAnsiBackground(JNIEnv *env, jclass cls, jint attr)
33{
34  return caca_attr_to_ansi_bg(attr);
35}
36
37JNIEXPORT jshort JNICALL
38Java_org_zoy_caca_Attribute_attributeToRgb12Foreground(JNIEnv *env, jclass cls, jint attr)
39{
40  return caca_attr_to_rgb12_fg(attr);
41}
42
43JNIEXPORT jshort JNICALL
44Java_org_zoy_caca_Attribute_attributeToRgb12Background(JNIEnv *env, jclass cls, jint attr)
45{
46  return caca_attr_to_rgb12_bg(attr);
47}
48
49JNIEXPORT jbyteArray JNICALL
50Java_org_zoy_caca_Attribute_attributeToArgb64(JNIEnv *env, jclass cls, jint attr)
51{
52  jbyteArray ret;
53  jbyte *elems;
54
55  ret = (*env)->NewByteArray(env, 8);
56  elems = (*env)->GetByteArrayElements(env, ret, 0);
57  caca_attr_to_argb64(attr, elems);
58  (*env)->ReleaseByteArrayElements(env, ret, elems, 0);
59
60  return ret;
61}
62
Note: See TracBrowser for help on using the repository browser.