Revision 4996

View differences:

trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GdalFile.java
245 245
	int lastY = -1;
246 246
	
247 247
	public void readLine(int[][] line) throws GdalException {
248
        int w = (int) Math.ceil(((double)currentViewWidth)*step);
248
        int w = (int) (Math.ceil(((double)currentViewWidth)*step) + 1);
249 249
        int x = (int) Math.ceil(currentViewX);
250 250
        int y = (int) Math.ceil(lastReadLine);
251 251
        GdalBuffer r = null, g = null, b = null, p = null;
......
276 276
  		lastReadLine += step;
277 277
  		
278 278
  		int i=0;
279
  		float j =0F;
279
  		double j = 0D;
280
  		double initOffset =  Math.abs(currentViewX - ((int)currentViewX));
280 281
  		
281 282
  		if (dataType == GDT_CInt16 || dataType == GDT_Int16  || dataType == GDT_UInt16){
282 283
  			if (g == null){ // Sibgle Band (Typical DEM)
283 284
  				for (int k=0; k<4; k++){
284
  					for (i=0, j=0F; i<currentViewWidth && j<r.getSize(); i++, j+=step) {
285
  					for (i=0, j = initOffset; i<currentViewWidth && j<r.getSize(); i++, j+=step) {
285 286
  						if(k<3)
286 287
  							line[i][k] = (r.buffShort[(int) j] & 0xffff);
287 288
  						else
......
292 293
  				//System.err.println("readLine(): Raster 16bits multibanda");
293 294
  				GdalBuffer [] bands = {r,g,b};
294 295
  				for (int k=0; k<4; k++){
295
		      		for (i=0, j=0F; i<currentViewWidth && j<r.getSize(); i++, j+=step){
296
		      		for (i=0, j = initOffset; i<currentViewWidth && j<r.getSize(); i++, j+=step){
296 297
		      			if(k<3)
297 298
		      				line[i][k] = (bands[k].buffShort[(int) j] & 0xffff);
298 299
		      			else
......
303 304
  		}else if(dataType == GDT_Float32){
304 305
  			GdalBuffer [] bands = {r,g,b};
305 306
			for (int k=0; k<4; k++){
306
	      		for (i=0, j=0F; i<currentViewWidth && j<r.getSize(); i++, j+=step){
307
	      		for (i=0, j = initOffset; i<currentViewWidth && j<r.getSize(); i++, j+=step){
307 308
	      			//Truncamos el float perdiendo centimetros. Es necesario para visualizar
308 309
	      			if(k < 3)
309 310
	      				line[i][k] = (int)bands[0].buffFloat[(int) j];
......
357 358
    				a.buffByte[i] = (byte)255;
358 359
        	}
359 360
        }
360

  
361 361
  		lastReadLine += step;
362 362
  	
363
  		
364 363
  		int i=0;
365 364
  		double j =  Math.abs(currentViewX - ((int)currentViewX));
366 365
		int alpha = (this.alpha & 0xff) << 24;

Also available in: Unified diff