if (imageWidth != imageHeight)
throw new RuntimeException("imageWidth: " + imageWidth
+ " != imageHeight: " + imageHeight);
size = imageWidth;
ImageRaster raster = getImageRaster();
heightData = new float[(imageWidth * imageHeight)];
ColorRGBA colorStore = new ColorRGBA();
int index = 0;
if (flipY) {
for (int h = 0; h < imageHeight; ++h) {
if (flipX) {
for (int w = imageWidth - 1; w >= 0; --w) {
//int baseIndex = (h * imageWidth)+ w;
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
}
} else {
for (int w = 0; w < imageWidth; ++w) {
//int baseIndex = (h * imageWidth)+ w;
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
}
}
}
} else {
for (int h = imageHeight - 1; h >= 0; --h) {
if (flipX) {
for (int w = imageWidth - 1; w >= 0; --w) {
//int baseIndex = (h * imageWidth)+ w;
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
}
} else {
for (int w = 0; w < imageWidth; ++w) {
//int baseIndex = (h * imageWidth)+ w;
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
}
}
}
}