Revision 1679 org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/buffer/cache/RasterReadOnlyBuffer.java

View differences:

RasterReadOnlyBuffer.java
113 113
	 */
114 114
	public RasterReadOnlyBuffer(int dataType, int width, int height, int nBand) {
115 115
		this.dataType = dataType;
116
				this.width = width;
117
				this.height = height;
118
				this.nBands = nBand;	
116
		this.width = width;
117
		this.height = height;
118
		this.nBands = nBand;	
119 119
	}
120 120
	
121 121
	/**
......
175 175
		this.maxX = maxX;
176 176
		this.maxY = maxY;
177 177
		
178
		if(Math.abs(maxX - minX) != width)
178
		if(Math.abs(maxX - minX) != width || Math.abs(maxY - minY) != height) {
179 179
			bufWidth = width;
180
		if(Math.abs(maxY - minY) != height) 
181 180
			bufHeight = height;
181
		}
182 182
					
183 183
		init();
184 184
	}
......
217 217
		}
218 218
		
219 219
		drawableBands = new int[datasource.getBandCount()];
220
			for (int i = 0; i < drawableBands.length; i++) 
220
		for (int i = 0; i < drawableBands.length; i++) 
221 221
			drawableBands[i] = i;
222 222
	}
223 223
	
......
283 283
	private Buffer queryPage(int pag) throws RasterDriverException, ProcessInterruptedException, InvalidSetViewException {
284 284
		int w = maxX - minX + 1;
285 285
		int h = maxY - minY + 1;
286
		
287
		if((minX + w) > datasource.getWidth())
288
			w = (int)(datasource.getWidth() - minX);
289
		
286 290
		if(bufWidth == 0 && bufHeight == 0) {
287 291
			if(pag == nPages - 1)
288 292
				query.setAreaOfInterest(minX, (blockHeight * pag) + minY, w, heightLastPage);
......
294 298
				int hLastPage = 0;
295 299
				if(heightLastPage == bufHeight) {
296 300
					hLastPage = h;
301
					hPage = 0;
297 302
				} else
298
					hLastPage = (int)Math.round((heightLastPage * bufHeight) / (double)h);
299
				query.setAreaOfInterest(minX, (hPage * pag) + minY, w, hLastPage, bufWidth, heightLastPage);
303
					hLastPage = (int)Math.round((heightLastPage * h) / (double)bufHeight);
304
				int newMiY = (hPage * pag) + minY;
305
				if((newMiY + hLastPage) > datasource.getHeight())
306
					hLastPage = (int)(datasource.getHeight() - newMiY);
307
				query.setAreaOfInterest(minX, newMiY, w, hLastPage, bufWidth, heightLastPage);
300 308
			} else 
301 309
				query.setAreaOfInterest(minX, (hPage * pag) + minY, w, hPage, bufWidth, blockHeight);
302 310
		}

Also available in: Unified diff