Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src-dvp / org / cresques / io / EcwWriter.java @ 1741

History | View | Annotate | Download (19.9 KB)

1
package org.cresques.io;
2

    
3
import java.io.IOException;
4

    
5
import es.gva.cit.jecwcompress.*;
6
import es.gva.cit.jgdal.GdalRasterBand;
7

    
8
import org.cresques.geo.ViewPortData;
9
import org.cresques.px.PxRaster;
10

    
11
/**
12
 * 
13
 * @author Nacho Brodin <brodin_ign@gva.es>
14
 *
15
 * Driver para la compresi?n en formato Ecw. 
16
 * 
17
 * Puede exportar un fichero desde un GeoRasterFile en cualquier formato soportado 
18
 * por los drivers de lectura a uno en formato Ecw.
19
 * 
20
 * Puede salvar a disco en formato Ecw obteniendo los datos que van siendo servidos 
21
 * desde el cliente. Este cliente debe implementar un IDataWriter o tener un objeto 
22
 * que lo implemente. Inicialmente le pasar? los par?metros de la imagen de salida 
23
 * y cuando el driver comience a escribir le ir? solicitando m?s a trav?s del m?todo 
24
 * readData de IDataWriter. El cliente ser? el que lleve el control de lo que va 
25
 * sirviendo y lo que le queda por servir.
26
 */
27

    
28
public class EcwWriter extends GeoRasterWriter{
29
        
30
        public final int windowSizeX = 386;
31
        public final int windowSizeY = 215;
32
        public final int panelSizeX = 350;
33
        public final int panelSizeY = 125;
34
        public final String panelLayout = "BorderLayout";
35
                
36
        private NCSEcwCompressClient        compressclient=null;
37
        private Reader                                         readerObj;
38
        private double                                        pixelSizeX;
39
        private double                                        pixelSizeY;
40
        private double                                        geoCoordOrigenX;
41
        private double                                        geoCoordOrigenY;
42
        private EcwSupportOptions                support = null;
43
        private boolean                                        consulta = false;
44
        
45
        /**
46
         * @author nacho
47
         *
48
         * TODO To change the template for this generated type comment go to
49
         * Window - Preferences - Java - Code Style - Code Templates
50
         */
51
        class EcwSupportOptions extends WriterSupportOptions{
52
                
53
                private String[]                 compresionListValues = {"0","20","10","1","5"}; //min, max, valor defecto, intervalo peque?o, intervalo grande;
54
                private String[]                formatList = {"NONE","UINT8","YUV","MULTI","RGB"};
55
                
56
                private int                                formatDefault = 4;
57
                private int                                compresionDefault = 10;
58
                
59
                EcwSupportOptions(){
60
                        super("Ecw");
61
                }
62
                
63
                /**
64
                 * Asigna la lista de valores de compresi?n
65
                 * @param compresion        lista de valores
66
                 */
67
                public void setCompressionList(String[] compresion){
68
                        this.compresionListValues = compresion;
69
                }
70
                
71
                /**
72
                 * Valor de formato seleccionado en el driver.
73
                 * 0-NONE, 1-UINT8, 2-YUV, 3-MULTI, 4-RGB
74
                 * @param i        valor de formato
75
                 */
76
                public void setFormatDefault(int i){
77
                        this.formatDefault = i;
78
                }
79
                
80
                /**
81
                 * Asigna el nivel de compresi?npor defecto
82
                 * @param compress        Nivel de compresi?n
83
                 */
84
                public void setCompressionDefault(int compress){
85
                        this.compresionDefault = compress;
86
                }
87
                
88
                /**
89
                 * Obtiene el tipo de imagen en un formato comprensible por el driver.
90
                 * @return        Tipo de imagen
91
                 */
92
                public String getStringFormat(){
93
                        return "COMPRESS_"+formatList[formatDefault];
94
                }
95
                
96
                /**
97
                 * Obtiene la lista de los tipos de formato disponible
98
                 * @return Lista de tipos de formato
99
                 */
100
                public String[] getFormatList(){
101
                        return formatList;
102
                }
103
                
104
                /**
105
                 * Obtiene el tipo de formato seleccionado en el driver
106
                 * @return Tipo de formato seleccionado
107
                 */
108
                public int getFormat(){return formatDefault;}
109
                
110
                /**
111
                 * Obtiene la compresion seleccionada
112
                 * @return Compresi?n seleccionada
113
                 */
114
                public int getCompression(){return compresionDefault;}
115
                
116
                /**
117
                 * Obtiene la lista de los valores para la generaci?n de la barra de 
118
                 * compresi?n. Son cinco valores m?nimo, m?ximo, seleccionado, 
119
                 * intervalo peque?o, intervalo grande.
120
                 * @return lista de valores de compresi?n
121
                 */
122
                public String[] getCompressionList(){return compresionListValues;}
123
                
124
        }
125
                
126
        static {
127
                GeoRasterWriter.registerWriterExtension("ecw", EcwWriter.class);
128
        }
129
        
130
        /**
131
         * Constructor para la obtenci?n de par?metros del driver.
132
         *
133
         */
134
        public EcwWriter(){
135
                
136
                this.support = new EcwSupportOptions();
137
                this.driver = "ecw";
138
                this.support.setBlockSize(64);
139
                this.support.setCompressionDefault(10);        
140
                this.support.setFormatDefault(4);
141
                this.support.setWriteGeoref(true);
142
                this.ident = "Ecw";
143
                this.consulta = true;
144
                
145
        }
146
        
147
        /**
148
         * Constructor para salvar una sola imagen completa
149
         * @param raster        PxRaster de la imagen origen
150
         * @param outfilename        Fichero de salida
151
         * @param infilename        Fichero de entrada
152
         * @param compresion        Compresi?n
153
         */
154
        
155
         public EcwWriter(        PxRaster raster, 
156
                                                String outfilename, 
157
                                                String infilename, 
158
                                                int compresion)throws EcwException, IOException {
159
 
160
                 this.support = new EcwSupportOptions();
161
                 this.ident = "Ecw";
162
                 
163
                this.outfilename = outfilename;
164
                this.infilename = infilename;
165
                this.currentRaster = raster;
166
                
167
                this.support.setCompressionDefault(compresion);                        
168
                                
169
                this.sizeWindowX = raster.getFWidth();
170
                this.sizeWindowY = raster.getFHeight();
171
                
172
                this.support.setBlockSize(currentRaster.geoFile.getBlockSize());
173
                                
174
                nBands = currentRaster.getBandCount();
175
                
176
                //Calculamos la georeferenciaci?n
177
             
178
            double maxX=currentRaster.getExtent().maxX();
179
            geoCoordOrigenX=currentRaster.getExtent().minX();
180
            geoCoordOrigenY=currentRaster.getExtent().maxY();
181
            double minY=currentRaster.getExtent().minY();
182
            double w=currentRaster.getFWidth();
183
            double h=currentRaster.getFHeight();
184
            pixelSizeX = (maxX-geoCoordOrigenX)/w;
185
            pixelSizeY = (minY-geoCoordOrigenY)/h;
186
                        
187
            if(sizeWindowX<0 || sizeWindowY<0)
188
                        throw new IOException("Tama?o del fichero de salida erroneo.");
189
            
190
            if(nBands == 1) 
191
                        this.support.setFormatDefault(CompressFormat.COMPRESS_UINT8);
192
                else if(nBands == 3) 
193
                        this.support.setFormatDefault(CompressFormat.COMPRESS_RGB);
194
                else 
195
                        this.support.setFormatDefault(CompressFormat.COMPRESS_MULTI);
196
            
197
                init();
198
                
199
        }
200
        
201
        
202
        
203
        /**
204
         * Constructor para la lectura de datos desde el objeto cliente a partir
205
         * de un viewport dado.
206
         * @param dataWriter        Objeto que sirve datos para el escritor
207
         * @param vp        viewport de origen
208
         * @param outFileName        Fichero de salida
209
         * @param blockSize        Tama?o de bloque
210
         * @param nBands        N?mero de bandas
211
         * @param compresion        Compresi?n
212
         * @throws EcwException
213
         * @throws IOException
214
         */
215
        
216
        public EcwWriter(        IDataWriter dataWriter, 
217
                                                ViewPortData vp,
218
                                                String outFileName, 
219
                                                int blockSize,
220
                                                int nBands,
221
                                                int compresion)throws EcwException, IOException {
222
                
223
                this.support = new EcwSupportOptions();
224
                this.ident = "Ecw";
225
                
226
                if(compresion <= 0)
227
                throw new EcwException("Tasa de compresi?n no valida.");
228
                if(nBands <= 0)
229
                throw new EcwException("N?mero de bandas erroneo.");
230
                if(vp.getWidth()<=0 || vp.getHeight()<=0)
231
                throw new EcwException("Tama?o de la imagen de salida erroneo.");
232
                
233
                this.outfilename = outFileName;
234
                this.dataWriter = dataWriter;
235
                this.support.setCompressionDefault(compresion);
236
                this.nBands = nBands;
237
                
238
                this.sizeWindowX = (int)vp.getWidth();
239
                this.sizeWindowY = (int)vp.getHeight();
240
                this.support.setBlockSize(blockSize);
241
                                
242
                //Calculamos la georeferenciaci?n a partir del extend pasado por el cliente.
243
                
244
                
245
                double maxX = vp.getExtent().maxX();
246
                geoCoordOrigenX = vp.getExtent().minX();
247
                geoCoordOrigenY = vp.getExtent().maxY();
248
                double minY = vp.getExtent().minY();
249
                pixelSizeX = (maxX-geoCoordOrigenX)/vp.getWidth();
250
                pixelSizeY = (minY-geoCoordOrigenY)/vp.getHeight();
251
                
252
                if(pixelSizeX==0)pixelSizeX=1.0;
253
                if(pixelSizeY==0)pixelSizeY=1.0;
254

    
255
                init();
256
                
257
        }
258
        
259
        
260
        /**
261
         * Inicializaci?n de los par?metros del compresor que ser?n obtenidos
262
         * de PxRaster.
263
         * @throws EcwException
264
         */
265
        
266
        private void init() throws EcwException{
267
                
268
                if(this.support.getCompression()==0)
269
                        this.support.setCompressionDefault(1);
270
                if(compressclient==null)
271
                        compressclient = new NCSEcwCompressClient();
272
                compressclient.setOutputFilename(outfilename);          
273
                  compressclient.setInputFilename(infilename);
274
            compressclient.setTargetCompress(this.support.getCompression());
275
            compressclient.setInOutSizeX(sizeWindowX);
276
            compressclient.setInOutSizeY(sizeWindowY);
277
            compressclient.setInputBands(nBands);
278
            compressclient.setCompressFormat(this.support.getFormat());
279
                       
280
            //System.out.println("Origen=>"+minX + "  "+maxY );
281
            //System.out.println("Pixel Size=>"+psX+"  "+psY);
282
            
283
            //compressclient.setDatum("UTM Zona 31N");
284
            //client.setProjection("WGS84");
285
            
286
            if(this.support.getGeoref()){
287
                        compressclient.setCellIncrementX(pixelSizeX);
288
                        compressclient.setCellIncrementY(pixelSizeY);
289
                        compressclient.setOriginX(geoCoordOrigenX);
290
                        compressclient.setOriginY(geoCoordOrigenY);
291
            }
292
            compressclient.setCellSizeUnits(1);
293

    
294
                //System.out.println(outfilename+" "+infilename+" "+compresion+" "+sizeWindowX+" "+sizeWindowY+" "+currentRaster.getBandCount());
295
                //System.out.println(psX+" "+psY+" "+minX+" "+maxX);
296
                
297
                if(currentRaster!=null)
298
                        readerObj = new Reader( currentRaster.geoFile, 
299
                                                                        compressclient, 
300
                                                                        ulX, 
301
                                                                        ulY, 
302
                                                                        sizeWindowX, 
303
                                                                        sizeWindowY, 
304
                                                                        this.support.getBlockSize());
305
                else if(dataWriter!=null)
306
                        readerObj = new Reader( dataWriter, 
307
                                                                        compressclient,  
308
                                                                        sizeWindowX, 
309
                                                                        sizeWindowY, 
310
                                                                        this.support.getBlockSize(),
311
                                                                        this.nBands);
312
                
313
                
314
        }
315
                
316
        /**
317
         * A partir de un elemento que contiene una propiedad y un valor
318
         * lo parsea y asigna el valor a su variable.
319
         * @param propValue        elemento con la forma propiedad=valor
320
         */
321
        private void readProperty(String propValue){
322
                
323
                String prop = propValue.substring(0, propValue.indexOf("="));
324
                if(propValue.startsWith(prop)){
325
                        String value = propValue.substring(propValue.indexOf("=")+1, propValue.length());
326
                        if(value!=null && !value.equals("")){
327
                                if(prop.equals("BLOCKSIZE"))
328
                                        this.support.setBlockSize(Integer.parseInt(value));
329
                                if(prop.equals("FORMAT")){
330
                                        int select = 0;
331
                                        if(value.equals("UINT8"))
332
                                                select = 1;
333
                                        if(value.equals("YUV"))
334
                                                select = 2;
335
                                        if(value.equals("MULTI"))
336
                                                select = 3;
337
                                        if(value.equals("RGB"))
338
                                                select = 4;
339
                                        this.support.setFormatDefault(select);
340
                                }
341
                                if(prop.equals("GEOREF")){
342
                                        boolean georef = true;
343
                                        if(value.equals("yes"))
344
                                                georef = true;
345
                                        else
346
                                                georef = false;
347
                                        this.support.setWriteGeoref(georef);
348
                                }        
349
                                if(prop.equals("COMPRESSION"))
350
                                        this.support.setCompressionDefault(Integer.parseInt(value));
351
                        }
352
                }
353
                
354
        }
355
        
356
        /**
357
         * Asigna propiedades al driver a partir de un vector de
358
         * strings donde cada elemento tiene la estructura de 
359
         * propiedad=valor.
360
         * @param props        Propiedades
361
         */
362
        public void setProps(String[] props){
363

    
364
                for(int iProps=0;iProps<props.length;iProps++)
365
                        readProperty(props[iProps]);
366
                
367
                try{
368
                        if(!consulta)init();
369
                }catch(EcwException e){
370
                        e.printStackTrace();
371
                }
372
                
373
        }
374
        
375
        /**
376
         * Realiza la funci?n de compresi?n a partir de un GeoRasterFile.
377
         * @throws IOException
378
         */
379
        
380
        public void fileWrite()throws IOException{
381

    
382
                if(currentRaster==null)
383
                        throw new IOException("No se ha asignado un fichero de entrada.");
384
                
385
                try{
386
                        compressclient.NCSEcwCompressOpen(false);
387
                        compressclient.NCSEcwCompress(readerObj);
388
                }catch(EcwException e){
389
                        e.printStackTrace();
390
                }
391
        }
392
        
393
        /**
394
         * Realiza la funci?n de compresi?n a partir de los datos pasados por el cliente.
395
         * @throws IOException
396
         */
397
        
398
        public void dataWrite()throws IOException{
399
                
400
                if(dataWriter==null)
401
                        throw new IOException("No se ha obtenido un objeto para la lectura valido.");
402
                
403
                try{
404
                        compressclient.NCSEcwCompressOpen(false);
405
                        compressclient.NCSEcwCompress(readerObj);
406
                }catch(EcwException e){
407
                        e.printStackTrace();
408
                }
409
                
410
        }
411
        
412
        /**
413
         * Cierra el compresor ecw.
414
         */
415
        
416
        public void writeClose(){
417
                
418
                try{
419
                        compressclient.NCSEcwCompressClose();
420
                }catch(EcwException e){
421
                        e.printStackTrace();
422
                }
423
                
424
        }
425
        
426
        /**
427
         * Devuelve la configuraci?n de la ventana de dialogo
428
         * para las propiedades del driver de escritura de Ecw.
429
         * @return XML de configuraci?n del dialogo.
430
         */
431
        public String getXMLPropertiesDialog(){
432
                
433
                StringBuffer         options = null;
434
                options = new StringBuffer();
435
                options.append("<window sizex=\""+this.windowSizeX+"\" sizey=\""+this.windowSizeY+"\">");
436
                options.append("<panel sizex=\""+this.panelSizeX+"\" sizey=\""+this.panelSizeY+"\" layout=\""+this.panelLayout+"\" border=\"yes\">");
437
                
438
                options.append("<panel layout=\"FlowLayout\" position=\"North\" align=\"left\">");
439
                options.append("<label>Tama?o bloque:</label>");
440
                options.append("<combo ident=\"BLOCKSIZE\" selected=\""+this.support.getBlockSize() +"\">");
441
                for(int i=0;i<this.support.getBlockSizeList().length;i++)
442
                        options.append("<elem>"+this.support.getBlockSizeList()[i]+"</elem>");
443
                options.append("</combo>");
444
                options.append("<label>Formato:</label>");
445
                String sel = null; 
446
                if(this.support.getGeoref())
447
                        sel = new String("yes");
448
                else 
449
                        sel = new String("no");
450
                options.append("<check ident=\"GEOREF\" selected=\""+sel +"\" text=\"Georef Si/No\">");
451
                options.append("</check>");
452
                options.append("</panel>");
453
                                                
454
                options.append("<panel layout=\"FlowLayout\" position=\"South\">");
455
                options.append("<slider ident=\"COMPRESSION\" name=\"Nivel de Compresi?n\" sizex=\"350\" sizey=\"20\">");
456
                options.append("<min>"+this.support.getCompressionList()[0]+"</min>");
457
                options.append("<max>"+this.support.getCompressionList()[1]+"</max>");
458
                options.append("<value>"+this.support.compresionDefault+"</value>");
459
                options.append("<minorspacing>"+this.support.getCompressionList()[3]+"</minorspacing>");
460
                options.append("<majorspacing>"+this.support.getCompressionList()[4]+"</majorspacing>");
461
                options.append("</slider>");
462
                options.append("</panel>");
463
                                
464
                options.append("</panel>");                                                                
465
                options.append("</window>");
466
                                                                                                
467
                return options.toString();
468
                
469
        }
470
        
471
}
472

    
473
/**
474
 * Clase que se encarga de la lectura de datos que ser?n escritos. Hereda de JniObject
475
 * para asegurar  para asegurar que el interfaz de la libreria tiene acceso a variables
476
 * necesarias para la petici?n de datos cuando vacia el buffer. Implementa ReadCallBack
477
 * para obligar escribir el m?todo loadBuffer encargado de servir los datos cuando el 
478
 * buffer se vacia.
479
 *
480
 */
481

    
482
class Reader extends JniObject implements ReadCallBack {
483
        
484
        
485
        private NCSEcwCompressClient         compressclient=null;
486
        private int                                         width, height;                        
487
        private int                                         ulX, ulY;
488
        private GeoRasterFile                         grf=null;
489
        private IDataWriter                                dataWriter=null;
490
        private GdalRasterBand                         rband=null;
491
        private int                                         blockSizeRead=1;                //Alto del bloque leido de la imagen origen 
492
        private int                                                countLine=1;                        //Contador de l?neas procesadas en cada lectura de bloque
493
        byte[][]                                                 buf=null;
494
        byte[]                                                         bufband1=null;
495
        byte[]                                                         bufband2=null;
496
        byte[]                                                         bufband3=null;
497
        byte[]                                                         bufband4=null;
498
        byte[]                                                         bufband5=null;
499
        byte[]                                                         bufband6=null;
500
        int[]                                                        dataBuffer=null;
501
        private int                                         lineasBloqueFinal=0;        //N?mero de l?neas leidas del bloque final
502
        private int                                         nBlocks=0;                                //N?mero de bloques completos
503
        private int                                                countBlock=1;                        //Contador de bloques completos procesados
504
        private int                                                nBands=0;
505
        
506
        /**
507
         * Constructor para la escritura de un fichero desde un GeoRasterFile
508
         * @param grf        GeorasterFile del fichero de origen
509
         * @param compressclient        Objeto que representa al compresor ecw
510
         * @param ulx        Coordenada X de la esquina superior izquierda
511
         * @param uly        Coordenada Y de la esquina superior izquierda
512
         * @param width        Ancho de la imagen
513
         * @param height        Alto de la imagen
514
         * @param blockSizeRead        Altura del bloque en la lectura        
515
         */
516
        public Reader(         GeoRasterFile grf, 
517
                                        NCSEcwCompressClient compressclient, 
518
                                        int ulx, 
519
                                        int uly, 
520
                                        int width, 
521
                                        int height,
522
                                        int blockSizeRead){
523
        
524
                this.compressclient = compressclient;
525
                this.width = width;
526
                this.height = height;
527
                this.ulX = ulx;
528
                this.ulY = uly;
529
                this.grf = grf;
530
                this.nBands = grf.bandCount;
531
                
532
                if(blockSizeRead!=0)
533
                        this.blockSizeRead = blockSizeRead;
534
                
535
                nBlocks = (int)(height/this.blockSizeRead);
536
                lineasBloqueFinal = height-(nBlocks*this.blockSizeRead);
537
                
538
                if(blockSizeRead>64)  
539
                        this.blockSizeRead=64;
540
        }
541
        
542
        /**
543
         * Constructor para que los datos sean servidos desde el cliente a trav?s de un 
544
         * IDataWriter.
545
         * @param dataWriter        Objeto servidor de datos del driver 
546
         * @param compressclient        Objeto que representa al compresor ecw
547
         * @param width        Ancho de la imagen
548
         * @param height        Alto de la imagen
549
         * @param blockSizeRead        Altura del bloque en la lectura
550
         * @param nBands        N?mero de bandas
551
         */
552
        public Reader(         IDataWriter dataWriter, 
553
                                        NCSEcwCompressClient compressclient, 
554
                                        int width, 
555
                                        int height,
556
                                        int blockSizeRead,
557
                                        int nBands){
558

    
559
                this.compressclient = compressclient;
560
                this.width = width;
561
                this.height = height;
562
                this.dataWriter =  dataWriter;
563
                this.nBands = nBands;
564
                
565
                if(blockSizeRead!=0)
566
                        this.blockSizeRead = blockSizeRead;
567
                
568
                nBlocks = (int)(height/this.blockSizeRead);
569
                lineasBloqueFinal = height-(nBlocks*this.blockSizeRead);
570
                
571
                //System.out.println("NBLOQUES="+nBlocks+" lineas ultimo="+lineasBloqueFinal);
572
                
573
                if(blockSizeRead>64)  
574
                        this.blockSizeRead=64;
575
        }
576
        
577
        /**
578
         * Lectura de bandas desde un GeoRasterFile
579
         * @param ulX        Coordenada X de la esquina superior izquierda
580
         * @param ulY        Coordenada Y de la esquina superior izquierda
581
         * @param width        Ancho de la imagen
582
         * @param lineasLeidas        N?mero de l?neas a leer del origen
583
         */
584
        
585
        private void readBandsGRFile(int ulX, int ulY, int width, int lineasLeidas){
586
                if(nBands>=1)
587
                        bufband1 = grf.getWindow(ulX, ulY, width, lineasLeidas, 1);
588
                if(nBands>=2)
589
                        bufband2 = grf.getWindow(ulX, ulY, width, lineasLeidas, 2);
590
                if(nBands>=3)
591
                        bufband3 = grf.getWindow(ulX, ulY, width, lineasLeidas, 3);
592
                if(nBands>=4)
593
                        bufband4 = grf.getWindow(ulX, ulY, width, lineasLeidas, 4);
594
                if(nBands>=5)
595
                        bufband5 = grf.getWindow(ulX, ulY, width, lineasLeidas, 5);
596
                if(nBands>=6)
597
                        bufband6 = grf.getWindow(ulX, ulY, width, lineasLeidas, 6);
598
        }
599
        
600
        /**
601
         * Lectura de bandas llamando al objeto cliente para que nos cargue el buffer
602
         * @param width        Ancho de la imagen
603
         * @param height        Alto de la imagen
604
         */
605
        
606
        private void readBands(int width, int height){
607
        
608
                dataBuffer = dataWriter.readData(width, height, 0);
609
        }
610
        
611
        /**
612
         * M?todo obligado por el interfaz y que es llamado desde C cuando el
613
         * compresor necesita que le sirvan m?s datos.
614
         */
615
        
616
        public void loadBuffer(){
617
                                                
618
                
619
                int lineasLeidas=0;
620
                
621
                //si se leen bloques completos lineasLeidas es == al tama?o de bloque sino
622
                //es que es el ?ltimo con lo que ser? del tama?o del bloque final
623
                
624
                if(countBlock<=nBlocks)lineasLeidas=blockSizeRead;
625
                        else lineasLeidas=lineasBloqueFinal;
626
                
627
                //Leemos un bloque nuevo cuando se han procesado todas las l?neas del anterior
628
                
629
                if(nNextLine%blockSizeRead==0){
630
                        if(grf!=null)
631
                                readBandsGRFile(ulX, ulY+nNextLine, width, lineasLeidas);
632
                        else if(dataWriter!=null)
633
                                readBands(width, lineasLeidas);
634
                        
635
                        countLine = 0;
636
                        countBlock++;
637
                }
638
                                
639
        
640
                for(int iBand=0;iBand<this.nBands;iBand++){
641
                                
642
                        for(int pos=0; pos<width; pos++){
643
                                if(grf!=null){
644
                                        if(iBand==0)
645
                                                compressclient.buffer[pos+(width*iBand)]=bufband1[pos+(width*countLine)];
646
                                        if(iBand==1)
647
                                                compressclient.buffer[pos+(width*iBand)]=bufband2[pos+(width*countLine)];
648
                                        if(iBand==2)
649
                                                compressclient.buffer[pos+(width*iBand)]=bufband3[pos+(width*countLine)];
650
                                        if(iBand==3)
651
                                                compressclient.buffer[pos+(width*iBand)]=bufband4[pos+(width*countLine)];
652
                                        if(iBand==4)
653
                                                compressclient.buffer[pos+(width*iBand)]=bufband5[pos+(width*countLine)];
654
                                        if(iBand==5)
655
                                                compressclient.buffer[pos+(width*iBand)]=bufband6[pos+(width*countLine)];
656
                                }else{
657
                                        if(iBand==0)
658
                                                compressclient.buffer[pos+(width*iBand)] = (byte)((dataBuffer[pos+(width*countLine)] & 0xff0000)>>16);
659
                                        if(iBand==1)
660
                                                compressclient.buffer[pos+(width*iBand)] = (byte)((dataBuffer[pos+(width*countLine)] & 0xff00)>>8);
661
                                        if(iBand==2)        
662
                                                compressclient.buffer[pos+(width*iBand)] = (byte)(dataBuffer[pos+(width*countLine)] & 0xff);
663
                                }
664
                                
665
                                if(pos==width-1 && iBand==this.nBands-1){
666
                                        countLine++;
667
                                }
668
                                
669
                        }
670
                                                
671

    
672
                        
673
                }
674
                                            
675
        }
676
        
677
        /**
678
         * M?todo obligado por el interfaz y que es llamado desde C cuando el
679
         * compresor actualiza el porcentaje de compresi?n
680
         */
681
        public void updatePercent(){
682
                System.out.println(compressclient.getPercent()+"%");
683
        }
684
        
685
}