what is wrong with my code ?
the result should be a gredient ...
Code:Image buffer = Image.createImage(width, height); Graphics buufg = buffer.getGraphics(); int[] gredientFrom = {255, 0, 212, 223}; int[] gredientTo = {255, 99, 20, 14}; int[] gredientDiff = new int[]{ gredientTo[0] - gredientFrom[0], gredientTo[1] - gredientFrom[1], gredientTo[2] - gredientFrom[2], gredientTo[3] - gredientFrom[3] }; int[] buffpx = new int[width * height]; for (int buffgox = 0; buffgox < width; buffgox++) { for (int buffgoy = 0; buffgoy < height; buffgoy++) { buffpx[buffgox + height * buffgoy] = ((gredientFrom[0] + (gredientDiff[0] * buffgox) / width) & 0xFF << 32) | ((gredientFrom[1] + (gredientDiff[1] * buffgox) / width) & 0xFF<< 16) | ((gredientFrom[2] + (gredientDiff[2] * buffgox) / width) & 0xFF<< 8) | (gredientFrom[3] + (gredientDiff[3] * buffgox) / width); } } buufg.drawRGB(buffpx, 0, height, 0, 0, width, height, true);

Reply With Quote

