svn-gvsig-desktop / tags / v1_2_Build_1205 / libraries / libjni-gdal / src / colortable_interfaz.c @ 33950
History | View | Annotate | Download (2.71 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: colortable_interfaz.c 7764 2006-10-03 07:04:43Z nacho $
|
3 |
*
|
4 |
* Name: colortable_interfaz.c
|
5 |
* Project: JGDAL. Interface java to gdal (Frank Warmerdam).
|
6 |
* Purpose: Color table
|
7 |
* Author: Nacho Brodin, brodin_ign@gva.es
|
8 |
*
|
9 |
**********************************************************************/
|
10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
11 |
*
|
12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
13 |
*
|
14 |
* This program is free software; you can redistribute it and/or
|
15 |
* modify it under the terms of the GNU General Public License
|
16 |
* as published by the Free Software Foundation; either version 2
|
17 |
* of the License, or (at your option) any later version.
|
18 |
*
|
19 |
* This program is distributed in the hope that it will be useful,
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
* GNU General Public License for more details.
|
23 |
*
|
24 |
* You should have received a copy of the GNU General Public License
|
25 |
* along with this program; if not, write to the Free Software
|
26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
27 |
*/
|
28 |
|
29 |
#include <jni.h> |
30 |
#include "es_gva_cit_jgdal_GdalRasterBand.h" |
31 |
#include "es_gva_cit_jgdal_JNIBase.h" |
32 |
#include "gdal.h" |
33 |
#include "cpl_string.h" |
34 |
|
35 |
/******************************************************************************/
|
36 |
// GetColorEntryCount
|
37 |
/******************************************************************************/
|
38 |
|
39 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jgdal_GdalColorTable_getColorEntryCountNat |
40 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
41 |
GDALColorTableH *hTable = (GDALColorTableH *) 0 ;
|
42 |
int res = -1; |
43 |
|
44 |
hTable = *(GDALColorTableH **)&cPtr; |
45 |
|
46 |
if(hTable != NULL) |
47 |
res = GDALGetColorEntryCount(hTable); |
48 |
|
49 |
return res;
|
50 |
} |
51 |
|
52 |
/******************************************************************************/
|
53 |
// GetColorEntryAsRGB
|
54 |
/******************************************************************************/
|
55 |
|
56 |
JNIEXPORT jshortArray JNICALL Java_es_gva_cit_jgdal_GdalColorTable_getColorEntryAsRGBNat |
57 |
(JNIEnv *env, jobject obj, jlong cPtr, jint pos){ |
58 |
short entryValues[4]; |
59 |
GDALColorEntry sEntry; |
60 |
jshortArray shortarray; |
61 |
GDALColorTableH *hTable = (GDALColorTableH *) 0 ;
|
62 |
|
63 |
hTable = *(GDALColorTableH **)&cPtr; |
64 |
|
65 |
if(hTable != NULL){ |
66 |
GDALGetColorEntryAsRGB( hTable, (int)pos, &sEntry );
|
67 |
entryValues[0] = sEntry.c1;
|
68 |
entryValues[1] = sEntry.c2;
|
69 |
entryValues[2] = sEntry.c3;
|
70 |
entryValues[3] = sEntry.c4;
|
71 |
|
72 |
shortarray = (*env)->NewShortArray(env, 4);
|
73 |
(*env)->SetShortArrayRegion(env, shortarray, 0, 4,(jshort *)entryValues); |
74 |
return shortarray;
|
75 |
} |
76 |
return NULL; |
77 |
} |