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 | |
---|
19 | JNIEXPORT jbyte JNICALL |
---|
20 | Java_org_zoy_caca_Attribute_attributeToAnsi(JNIEnv *env, jclass cls, jint attr) |
---|
21 | { |
---|
22 | return caca_attr_to_ansi(attr); |
---|
23 | } |
---|
24 | |
---|
25 | JNIEXPORT jbyte JNICALL |
---|
26 | Java_org_zoy_caca_Attribute_attributeToAnsiForeground(JNIEnv *env, jclass cls, jint attr) |
---|
27 | { |
---|
28 | return caca_attr_to_ansi_fg(attr); |
---|
29 | } |
---|
30 | |
---|
31 | JNIEXPORT jbyte JNICALL |
---|
32 | Java_org_zoy_caca_Attribute_attributeToAnsiBackground(JNIEnv *env, jclass cls, jint attr) |
---|
33 | { |
---|
34 | return caca_attr_to_ansi_bg(attr); |
---|
35 | } |
---|
36 | |
---|
37 | JNIEXPORT jshort JNICALL |
---|
38 | Java_org_zoy_caca_Attribute_attributeToRgb12Foreground(JNIEnv *env, jclass cls, jint attr) |
---|
39 | { |
---|
40 | return caca_attr_to_rgb12_fg(attr); |
---|
41 | } |
---|
42 | |
---|
43 | JNIEXPORT jshort JNICALL |
---|
44 | Java_org_zoy_caca_Attribute_attributeToRgb12Background(JNIEnv *env, jclass cls, jint attr) |
---|
45 | { |
---|
46 | return caca_attr_to_rgb12_bg(attr); |
---|
47 | } |
---|
48 | |
---|
49 | JNIEXPORT jbyteArray JNICALL |
---|
50 | Java_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 | |
---|