GraphicsUtil.java
- import javax.microedition.lcdui.Image;
- /**
- *
- * @author Jagie
- *
- */
- public class GraphicsUtil {
- public static final int SHIFT_RED_TO_GREEN = 0;
- public static final int SHIFT_RED_TO_BLUE = 1;
- public static final int SHIFT_GREEN_TO_BLUE = 2;
- public static final int SHIFT_GREEN_TO_RED = 3;
- public static final int SHIFT_BLUE_TO_RED = 4;
- public static final int SHIFT_BLUE_TO_GREEN = 5;
- public static int[] flipImageColor(Image source, int shiftType) {
- // we start by getting the image data into an int array - the number
- // of 32-bit ints is equal to the width multiplied by the height
- int[] rgbData = new int[(source.getWidth() * source.getHeight())];
- source.getRGB(rgbData, 0, source.getWidth(), 0, 0, source.getWidth(),
- source.getHeight());
- // now go through every pixel and adjust it's color
- for (int i = 0; i < rgbData.length; i++) {
- int p = rgbData[i];
- // split out the different byte components of the pixel by
- // applying
- // a mask so we only get what we need, then shift it to make it
- // a normal number we can play around with
本文关键:在MIDP2.0中操作图片像素