root / trunk / libraries / libjni-mrsid / src / ltiimagestage.cpp @ 1180
History | View | Annotate | Download (4.2 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: ltiimagestage.cpp 1180 2005-01-25 12:04:45Z igbrotru $
|
3 |
*
|
4 |
* Name: ltiimagestage.c
|
5 |
* Project: JMRSID. Interfaz java to MrSID (Lizardtech).
|
6 |
* Purpose:
|
7 |
* Author: Nacho Brodin, brodin_ign@gva.es
|
8 |
*
|
9 |
**********************************************************************/
|
10 |
/*Copyright (C) 2004 Nacho Brodin <brodin_ign@gva.es>
|
11 |
|
12 |
This program is free software; you can redistribute it and/or
|
13 |
modify it under the terms of the GNU General Public License
|
14 |
as published by the Free Software Foundation; either version 2
|
15 |
of the License, or (at your option) any later version.
|
16 |
|
17 |
This program is distributed in the hope that it will be useful,
|
18 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
GNU General Public License for more details.
|
21 |
|
22 |
You should have received a copy of the GNU General Public License
|
23 |
along with this program; if not, write to the Free Software
|
24 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
25 |
*/
|
26 |
|
27 |
|
28 |
#include <jni.h> |
29 |
#include <malloc.h> |
30 |
#include "es_gva_cit_jmrsid_LTIImageStage.h" |
31 |
#include "es_gva_cit_jmrsid_JNIBase.h" |
32 |
|
33 |
#include "lt_types.h" |
34 |
#include "lt_base.h" |
35 |
#include "lt_fileSpec.h" |
36 |
#include "lti_geoCoord.h" |
37 |
#include "lti_pixel.h" |
38 |
#include "lti_navigator.h" |
39 |
#include "lti_sceneBuffer.h" |
40 |
#include "lti_metadataDatabase.h" |
41 |
#include "lti_metadataRecord.h" |
42 |
#include "lti_utils.h" |
43 |
#include "MrSIDImageReader.h" |
44 |
#include "J2KImageReader.h" |
45 |
#include "lti_imageReader.h" |
46 |
#include "lti_sceneBuffer.h" |
47 |
#include "lti_scene.h" |
48 |
//#include "cpl_conv.h"
|
49 |
#include "TIFFImageWriter.h" |
50 |
#include "../include/jmrsid.h" |
51 |
|
52 |
LT_USE_NAMESPACE(LizardTech); |
53 |
|
54 |
/******************************************************************************/
|
55 |
// read
|
56 |
/******************************************************************************/
|
57 |
|
58 |
|
59 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_LTIImageStage_readNat |
60 |
(JNIEnv *env, jobject obj, jlong cPtr, jlong cPtrscene, jlong cPtr_scenebuffer,jlong cPtrbuffer, jobject objbuf){ |
61 |
|
62 |
LTIScene *scene; |
63 |
LTISceneBuffer *buffer; |
64 |
LTIImageStage *img; |
65 |
t_buffer *str_buffer=NULL;
|
66 |
jclass class_mrsidbuffer; |
67 |
jfieldID id_b1,id_b2,id_b3,fid; |
68 |
jbyteArray jvect_byte1,jvect_byte2,jvect_byte3; |
69 |
int size;
|
70 |
|
71 |
img = *(LTIImageStage **)&cPtr; |
72 |
scene = *(LTIScene **)&cPtrscene; |
73 |
buffer = *(LTISceneBuffer **)&cPtr_scenebuffer; |
74 |
|
75 |
//Obtenemos el puntero al buffer. La llamada al constructor de SceneBuffer fue con el flag a 1.
|
76 |
|
77 |
if(cPtrbuffer!=-1){ |
78 |
str_buffer = *(t_buffer **)&cPtrbuffer; |
79 |
} |
80 |
|
81 |
//Llamamos a read
|
82 |
|
83 |
int res=img->read(*scene,*buffer);
|
84 |
|
85 |
if(str_buffer!=NULL){ |
86 |
|
87 |
//Obtenemos el tama?o
|
88 |
|
89 |
class_mrsidbuffer = env->GetObjectClass(objbuf); |
90 |
fid = env->GetFieldID( class_mrsidbuffer, "size", "I"); |
91 |
size = env->GetIntField( objbuf, fid); |
92 |
|
93 |
//Cargamos los datos en el buffer si la llamada fue con flag a 1
|
94 |
|
95 |
id_b1 = env->GetFieldID( class_mrsidbuffer, "buf1", "[B"); |
96 |
jvect_byte1 = env->NewByteArray(size); |
97 |
env->SetByteArrayRegion(jvect_byte1, 0, size,(jbyte *)str_buffer->bufs[0]); |
98 |
env->SetObjectField( objbuf, id_b1, jvect_byte1); |
99 |
|
100 |
id_b2 = env->GetFieldID( class_mrsidbuffer, "buf2", "[B"); |
101 |
jvect_byte2 = env->NewByteArray(size); |
102 |
env->SetByteArrayRegion(jvect_byte2, 0, size,(jbyte *)str_buffer->bufs[1]); |
103 |
env->SetObjectField( objbuf, id_b2, jvect_byte2); |
104 |
|
105 |
id_b3 = env->GetFieldID( class_mrsidbuffer, "buf3", "[B"); |
106 |
jvect_byte3 = env->NewByteArray(size); |
107 |
env->SetByteArrayRegion(jvect_byte3, 0, size,(jbyte *)str_buffer->bufs[2]); |
108 |
env->SetObjectField( objbuf, id_b3, jvect_byte3); |
109 |
|
110 |
//Esto lo haremos en el destructor de LTISceneBuffer
|
111 |
//delete(str_buffer->membuf);
|
112 |
//free(str_buffer);
|
113 |
} |
114 |
return res;
|
115 |
|
116 |
} |
117 |
|
118 |
/******************************************************************************/
|
119 |
// ~LTIImageStage
|
120 |
/******************************************************************************/
|
121 |
|
122 |
JNIEXPORT void JNICALL Java_es_gva_cit_jmrsid_LTIImageStage_FreeLTIImageStageNat
|
123 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
124 |
|
125 |
LTIImageStage *stage = (LTIImageStage *) 0 ;
|
126 |
|
127 |
stage = *(LTIImageStage **)&cPtr; |
128 |
if(stage!=NULL){ |
129 |
delete stage;
|
130 |
} |
131 |
|
132 |
} |