progress.setProgress(y / (float) img.getHeight());
for (int x = 0; x < img.getWidth(); x++) {
float u = (float) (x + px * img.getWidth()) / (float) globalXres;
float v = (float) (y + py * img.getHeight()) / (float) globalYres;
final Vector4 col;
if (tce == null) col = c.valueRGBA(u, v);
else col = tce.sample(x, y);
final Vector3 color = new Vector3();
int val;
// !!UGH TODO: optimize this!!
if (mode == 0) {
color.set(col.getVector3());
val = Utils.vector3ToINTColor(color);
} else if (mode == 1) {
float bg = ((((x + y) / 8) % 2) != 0) ? 1.0f : 0.75f;
col.x = col.x * col.w + bg * (1.0f - col.w);
col.y = col.y * col.w + bg * (1.0f - col.w);
col.z = col.z * col.w + bg * (1.0f - col.w);
color.set(col.getVector3());
val = Utils.vector3ToINTColor(color);
} else if (mode == 2) {
color.set(col.w);
val = Utils.vector3ToINTColor(color);
} else if (mode == 3) {
color.set(col.getVector3());
val = Utils.vector4ToINTColor_ARGB(col);
} else {
Logger.logError(null, "Wrong in computeImage");
val = Utils.vector3ToINTColor(color);
}