Java 类org.newdawn.slick.ImageBuffer 实例源码

项目:trashjam2017    文件:ImageBufferEndianTest.java   
public void init(GameContainer container) throws SlickException {
   // detect what endian we have
   if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
          endian = "Big endian";
       } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
          endian = "Little endian";
       } else
          endian = "no idea";

   redImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);

   blueImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);

   fromRed = redImageBuffer.getImage();
   fromBlue = blueImageBuffer.getImage();
}
项目:Progetto-C    文件:ImageBufferEndianTest.java   
public void init(GameContainer container) throws SlickException {
   // detect what endian we have
   if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
          endian = "Big endian";
       } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
          endian = "Little endian";
       } else
          endian = "no idea";

   redImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);

   blueImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);

   fromRed = redImageBuffer.getImage();
   fromBlue = blueImageBuffer.getImage();
}
项目:BaseClient    文件:ImageBufferEndianTest.java   
public void init(GameContainer container) throws SlickException {
   // detect what endian we have
   if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
          endian = "Big endian";
       } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
          endian = "Little endian";
       } else
          endian = "no idea";

   redImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);

   blueImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);

   fromRed = redImageBuffer.getImage();
   fromBlue = blueImageBuffer.getImage();
}
项目:Gorillaz    文件:Assets.java   
/** Generate an Error Image in Memory, since this will always proceed.
 * @return the generated ERROR_IMAGE or the cached version
 */
private static Image createErrorImage() {
    if (ERROR_IMAGE == null){
        ImageBuffer buf = new ImageBuffer(32, 32);

        // Flood Fill Magenta
        for (int y = 0; y < buf.getHeight(); y++) {
            for (int x = 0; x < buf.getWidth(); x++) {
                buf.setRGBA(x, y, 255, 0, 255, 255);
            }
        }

        // Draw an White Outline 2 px wide
        for (int y = 0; y < buf.getHeight(); y++) {
            buf.setRGBA(0, y, 255, 255, 255, 255);
            buf.setRGBA(1, y, 255, 255, 255, 255);
            buf.setRGBA(buf.getWidth() - 1, y, 255, 255, 255, 255);
            buf.setRGBA(buf.getWidth() - 2, y, 255, 255, 255, 255);
        }

        // Cache the generated Image
        ERROR_IMAGE = buf.getImage();
    }

    return ERROR_IMAGE;
}
项目:GPVM    文件:ImageBufferEndianTest.java   
public void init(GameContainer container) throws SlickException {
   // detect what endian we have
   if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
          endian = "Big endian";
       } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
          endian = "Little endian";
       } else
          endian = "no idea";

   redImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);

   blueImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);

   fromRed = redImageBuffer.getImage();
   fromBlue = blueImageBuffer.getImage();
}
项目:SpaceStationAlpha    文件:ImageBufferEndianTest.java   
public void init(GameContainer container) throws SlickException {
   // detect what endian we have
   if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
          endian = "Big endian";
       } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
          endian = "Little endian";
       } else
          endian = "no idea";

   redImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);

   blueImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);

   fromRed = redImageBuffer.getImage();
   fromBlue = blueImageBuffer.getImage();
}
项目:cretion    文件:ImageBufferEndianTest.java   
public void init(GameContainer container) throws SlickException {
   // detect what endian we have
   if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
          endian = "Big endian";
       } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
          endian = "Little endian";
       } else
          endian = "no idea";

   redImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);

   blueImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);

   fromRed = redImageBuffer.getImage();
   fromBlue = blueImageBuffer.getImage();
}
项目:JavaRA    文件:ShpTexture.java   
/**
    * Gets ImageBuffer for single .SHP frame with specified remapping color
    * @param index index of .SHP frame
    * @param remapColor team color
    * @return ImageBuffer for remapped texture
    */
   public Image getAsImage(int index, Color remapColor) {
// Check image in cache
Image res = RemappedTextureCache.getInstance().checkInCache(shp.getFileName(), remapColor, index);
if (res != null) {
    return res;
}

// Image is not cached, remap palette, generate image and cache it
ImageBuffer imgbuf = remapShpFrame(index, remapColor);

// Cache image and return
Image img = imgbuf.getImage();
RemappedTextureCache.getInstance().putInCache(img, shp.getFileName(), remapColor, index);
return img;
   }
项目:JavaRA    文件:ShpTexture.java   
private ImageBuffer remapShpShadowFrame(int index) {
Color shadowColors[] = new Color[] {
    new Color(0, 0, 0, 0), Color.green,
    Color.blue, Color.yellow,
    Color.black,
    new Color(0, 0, 0, 160),
    new Color(0, 0, 0, 128),
    new Color(0, 0, 0, 64),
};


ByteBuffer bb = shp.getImage(index);
ImageBuffer imgbuf = new ImageBuffer(shp.width(), shp.height());
for (int y = 0; y < shp.height(); y++) {
    for (int x = 0; x < shp.width(); x++) {
    int colorValue = bb.get() & 0xFF;

    imgbuf.setRGBA(x, y, shadowColors[colorValue % 8].getRed(), shadowColors[colorValue % 8].getGreen(), shadowColors[colorValue % 8].getBlue(), shadowColors[colorValue % 8].getAlpha());
    }
}

bb.rewind();

return imgbuf;
   }
项目:slick2d-maven    文件:ImageBufferEndianTest.java   
public void init(GameContainer container) throws SlickException {
   // detect what endian we have
   if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
          endian = "Big endian";
       } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
          endian = "Little endian";
       } else
          endian = "no idea";

   redImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);

   blueImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);

   fromRed = redImageBuffer.getImage();
   fromBlue = blueImageBuffer.getImage();
}
项目:javacup    文件:PlayerRenderNew.java   
public Image toSlick(java.awt.Image src) {
  BufferedImage
      b =
      new BufferedImage(src.getWidth(null), src.getHeight(null), BufferedImage.TYPE_INT_ARGB);
  b.createGraphics().drawImage(src, 0, 0, null);
  ImageBuffer buf = new ImageBuffer(b.getWidth(), b.getHeight());
  int x, y, argb;
  for (y = 0; y < b.getHeight(); y++) {
    for (x = 0; x < b.getWidth(); x++) {
      argb = b.getRGB(x, y);
      buf.setRGBA(x, y, (argb >> 16) & 0xff, (argb >> 8) & 0xff, argb & 0xff,
                  (argb >> 24) & 0xff);
    }
  }
  return buf.getImage();
}
项目:trashjam2017    文件:Gradient.java   
/**
 * Generate the image used for texturing the gradient across shapes
 */
public void genImage() {
    if (image == null) {
        ImageBuffer buffer = new ImageBuffer(128,16);
        for (int i=0;i<128;i++) {
            Color col = getColorAt(i / 128.0f);
            for (int j=0;j<16;j++) {
                buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
            }
        }
        image = buffer.getImage();
    }
}
项目:trashjam2017    文件:ImageBufferTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    ImageBuffer buffer = new ImageBuffer(320,200);
    for (int x=0;x<320;x++) {
        for (int y=0;y<200;y++) {
            if (y == 20) {
                buffer.setRGBA(x, y, 255,255,255,255);
            } else {
                buffer.setRGBA(x, y, x,y,0,255);
            }
        }
    }
    image = buffer.getImage();
}
项目:Progetto-C    文件:Gradient.java   
/**
 * Generate the image used for texturing the gradient across shapes
 */
public void genImage() {
    if (image == null) {
        ImageBuffer buffer = new ImageBuffer(128,16);
        for (int i=0;i<128;i++) {
            Color col = getColorAt(i / 128.0f);
            for (int j=0;j<16;j++) {
                buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
            }
        }
        image = buffer.getImage();
    }
}
项目:Progetto-C    文件:ImageBufferTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    ImageBuffer buffer = new ImageBuffer(320,200);
    for (int x=0;x<320;x++) {
        for (int y=0;y<200;y++) {
            if (y == 20) {
                buffer.setRGBA(x, y, 255,255,255,255);
            } else {
                buffer.setRGBA(x, y, x,y,0,255);
            }
        }
    }
    image = buffer.getImage();
}
项目:BaseClient    文件:Gradient.java   
/**
 * Generate the image used for texturing the gradient across shapes
 */
public void genImage() {
    if (image == null) {
        ImageBuffer buffer = new ImageBuffer(128,16);
        for (int i=0;i<128;i++) {
            Color col = getColorAt(i / 128.0f);
            for (int j=0;j<16;j++) {
                buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
            }
        }
        image = buffer.getImage();
    }
}
项目:BaseClient    文件:ImageBufferTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    ImageBuffer buffer = new ImageBuffer(320,200);
    for (int x=0;x<320;x++) {
        for (int y=0;y<200;y++) {
            if (y == 20) {
                buffer.setRGBA(x, y, 255,255,255,255);
            } else {
                buffer.setRGBA(x, y, x,y,0,255);
            }
        }
    }
    image = buffer.getImage();
}
项目:javaleagueframework    文件:PintaJugadorNew.java   
/**Cambia los colores de una imagen*/
public Image changeColor(Image img, float[] hueRatios, Color[] colors, boolean flip) throws SlickException {
    int width = img.getWidth();
    int height = img.getHeight();
    ImageBuffer imgBuf = new ImageBuffer(width, height);
    Color c;
    float[] v1 = new float[3];
    float[] v2 = new float[3];
    float brillo = 0;
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            for (int k = 0; k < colors.length; k = k + 2) {
                v1 = java.awt.Color.RGBtoHSB(colors[k].getRed(), colors[k].getGreen(), colors[k].getBlue(), v1);//HSB del color a cambiar
                c = img.getColor(i, j);
                v2 = java.awt.Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), v2);//HSB del color del pixel
                brillo = v2[2] - v1[2];
                if ((c.getAlpha() > 0) && (Math.abs(v2[0] - v1[0]) < hueRatios[k / 2] || Math.abs(v1[0] + 1 - v2[0]) < hueRatios[k / 2])) {//optimizar... no repetir
                    v1 = java.awt.Color.RGBtoHSB(colors[k + 1].getRed(), colors[k + 1].getGreen(), colors[k + 1].getBlue(), v1);//HSB del color al que se cambiara
                    brillo = v1[2] + brillo;
                    if (brillo < 0) {
                        brillo = 0;
                    }
                    if (brillo > 1) {
                        brillo = 1;
                    }
                    c = new Color(java.awt.Color.HSBtoRGB(v1[0], v1[1], brillo));
                    k = colors.length;
                }
                if (flip) {
                    imgBuf.setRGBA(width - i - 1, j, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
                } else {
                    imgBuf.setRGBA(i, j, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
                }
            }
        }
    }
    return imgBuf.getImage();
}
项目:javaleagueframework    文件:PintaJugadorNew.java   
public Image toSlick(java.awt.Image src) {
    BufferedImage b = new BufferedImage(src.getWidth(null), src.getHeight(null), BufferedImage.TYPE_INT_ARGB);
    b.createGraphics().drawImage(src, 0, 0, null);
    ImageBuffer buf = new ImageBuffer(b.getWidth(), b.getHeight());
    int x, y, argb;
    for (y = 0; y < b.getHeight(); y++) {
        for (x = 0; x < b.getWidth(); x++) {
            argb = b.getRGB(x, y);
            buf.setRGBA(x, y, (argb >> 16) & 0xff, (argb >> 8) & 0xff, argb & 0xff, (argb >> 24) & 0xff);
        }
    }
    return buf.getImage();
}
项目:GPVM    文件:Gradient.java   
/**
 * Generate the image used for texturing the gradient across shapes
 */
public void genImage() {
    if (image == null) {
        ImageBuffer buffer = new ImageBuffer(128,16);
        for (int i=0;i<128;i++) {
            Color col = getColorAt(i / 128.0f);
            for (int j=0;j<16;j++) {
                buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
            }
        }
        image = buffer.getImage();
    }
}
项目:GPVM    文件:Gradient.java   
/**
 * Generate the image used for texturing the gradient across shapes
 */
public void genImage() {
    if (image == null) {
        ImageBuffer buffer = new ImageBuffer(128,16);
        for (int i=0;i<128;i++) {
            Color col = getColorAt(i / 128.0f);
            for (int j=0;j<16;j++) {
                buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
            }
        }
        image = buffer.getImage();
    }
}
项目:GPVM    文件:ImageBufferTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    ImageBuffer buffer = new ImageBuffer(320,200);
    for (int x=0;x<320;x++) {
        for (int y=0;y<200;y++) {
            if (y == 20) {
                buffer.setRGBA(x, y, 255,255,255,255);
            } else {
                buffer.setRGBA(x, y, x,y,0,255);
            }
        }
    }
    image = buffer.getImage();
}
项目:SpaceStationAlpha    文件:Gradient.java   
/**
 * Generate the image used for texturing the gradient across shapes
 */
public void genImage() {
    if (image == null) {
        ImageBuffer buffer = new ImageBuffer(128,16);
        for (int i=0;i<128;i++) {
            Color col = getColorAt(i / 128.0f);
            for (int j=0;j<16;j++) {
                buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
            }
        }
        image = buffer.getImage();
    }
}
项目:SpaceStationAlpha    文件:ImageBufferTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    ImageBuffer buffer = new ImageBuffer(320,200);
    for (int x=0;x<320;x++) {
        for (int y=0;y<200;y++) {
            if (y == 20) {
                buffer.setRGBA(x, y, 255,255,255,255);
            } else {
                buffer.setRGBA(x, y, x,y,0,255);
            }
        }
    }
    image = buffer.getImage();
}
项目:cretion    文件:Gradient.java   
/**
 * Generate the image used for texturing the gradient across shapes
 */
public void genImage() {
    if (image == null) {
        ImageBuffer buffer = new ImageBuffer(128,16);
        for (int i=0;i<128;i++) {
            Color col = getColorAt(i / 128.0f);
            for (int j=0;j<16;j++) {
                buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
            }
        }
        image = buffer.getImage();
    }
}
项目:cretion    文件:ImageBufferTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    ImageBuffer buffer = new ImageBuffer(320,200);
    for (int x=0;x<320;x++) {
        for (int y=0;y<200;y++) {
            if (y == 20) {
                buffer.setRGBA(x, y, 255,255,255,255);
            } else {
                buffer.setRGBA(x, y, x,y,0,255);
            }
        }
    }
    image = buffer.getImage();
}
项目:JavaRA    文件:ShpTexture.java   
private ImageBuffer remapShpFrame(int index, Color remapColor) {
PalFile pal = ResourceManager.getInstance().getPaletteByName(this.palleteName == null ? "temperat.pal" : this.palleteName);
Color[] colors = new Color[256];

// Remap pallete only if remapping color is specified
remapPallete(colors, pal, remapColor);

ByteBuffer bb = shp.getImage(index);
ImageBuffer imgbuf = new ImageBuffer(shp.width(), shp.height());
for (int y = 0; y < shp.height(); y++) {
    for (int x = 0; x < shp.width(); x++) {
    int colorValue = bb.get() & 0xFF;

    // Check for shadow color
    if (colorValue != 0x04 && colorValue != 0x03) {
        if (forcedColor == null) {
        imgbuf.setRGBA(x, y, colors[colorValue].getRed(), colors[colorValue].getGreen(), colors[colorValue].getBlue(), (colorValue == 0) ? 0 : 255);
        } else {
        imgbuf.setRGBA(x, y, forcedColor.getRed(), forcedColor.getGreen(), forcedColor.getBlue(), (colorValue == 0) ? 0 : forcedColor.getAlpha());
        }
    } else {
        // Shadows
        imgbuf.setRGBA(x, y, 0, 0, 0, 128); // Replace shadow color with black color with 3/4 transparency
    }
    }
}

bb.rewind();

return imgbuf;
   }
项目:slick2d-maven    文件:Gradient.java   
/**
 * Generate the image used for texturing the gradient across shapes
 */
public void genImage() {
    if (image == null) {
        ImageBuffer buffer = new ImageBuffer(128,16);
        for (int i=0;i<128;i++) {
            Color col = getColorAt(i / 128.0f);
            for (int j=0;j<16;j++) {
                buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
            }
        }
        image = buffer.getImage();
    }
}
项目:slick2d-maven    文件:ImageBufferTest.java   
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
    ImageBuffer buffer = new ImageBuffer(320,200);
    for (int x=0;x<320;x++) {
        for (int y=0;y<200;y++) {
            if (y == 20) {
                buffer.setRGBA(x, y, 255,255,255,255);
            } else {
                buffer.setRGBA(x, y, x,y,0,255);
            }
        }
    }
    image = buffer.getImage();
}
项目:javaleagueframework    文件:PintaJugador.java   
/**Actualiza los cambios sobre la implementacion en los graficos
 */
public synchronized void update(boolean alternativa) throws SlickException {
    int idx;
    Color c0, c1 = null;
    Color upolera = alternativa?new Color(impl.getShirtColor2().getRed(), impl.getShirtColor2().getGreen(), impl.getShirtColor2().getBlue()):new Color(impl.getShirtColor().getRed(), impl.getShirtColor().getGreen(), impl.getShirtColor().getBlue());
    Color upantalon = alternativa?new Color(impl.getShortsColor2().getRed(), impl.getShortsColor2().getGreen(), impl.getShortsColor2().getBlue()):new Color(impl.getShortsColor().getRed(), impl.getShortsColor().getGreen(), impl.getShortsColor().getBlue());
    Color ucalcetas = alternativa?new Color(impl.getSocksColor2().getRed(), impl.getSocksColor2().getGreen(), impl.getSocksColor2().getBlue()):new Color(impl.getSocksColor().getRed(), impl.getSocksColor().getGreen(), impl.getSocksColor().getBlue());
    Color uportero = alternativa?new Color(impl.getGoalKeeper2().getRed(), impl.getGoalKeeper2().getGreen(), impl.getGoalKeeper2().getBlue()):new Color(impl.getGoalKeeper().getRed(), impl.getGoalKeeper().getGreen(), impl.getGoalKeeper().getBlue());
    Color ufranja = alternativa?new Color(impl.getShirtLineColor2().getRed(), impl.getShirtLineColor2().getGreen(), impl.getShirtLineColor2().getBlue()):new Color(impl.getShirtLineColor().getRed(), impl.getShirtLineColor().getGreen(), impl.getShirtLineColor().getBlue());

    for (int i = 0; i < 11; i++) {
        Color upelo = new Color(impl.getPlayers()[i].getHairColor().getRed(), impl.getPlayers()[i].getHairColor().getGreen(), impl.getPlayers()[i].getHairColor().getBlue());
        Color upiel = new Color(impl.getPlayers()[i].getSkinColor().getRed(), impl.getPlayers()[i].getSkinColor().getGreen(), impl.getPlayers()[i].getSkinColor().getBlue());
        for (int j = 0; j < 14; j++) {
            if (j < 7) {
                idx = j;
            } else {
                idx = (13 - j);
            }
            ImageBuffer ib = new ImageBuffer(20, 20);
            for (int x = 0; x < 20; x++) {
                for (int y = 0; y < 20; y++) {
                    c0 = img[idx][(alternativa?impl.getStyle2():impl.getStyle()).getNumero() - 1].getColor(x, y);
                    c1 = null;
                    if (c0.equals(franja)) {
                        if (impl.getPlayers()[i].isGoalKeeper()) {
                            c1 = uportero;
                        } else {
                            c1 = ufranja;
                        }
                    } else if (c0.equals(polera)) {
                        if (impl.getPlayers()[i].isGoalKeeper()) {
                            c1 = uportero;
                        } else {
                            c1 = upolera;
                        }
                    } else if (c0.equals(piel)) {
                        c1 = upiel;
                    } else if (c0.equals(pelo)) {
                        c1 = upelo;
                    } else if (c0.equals(pantalon)) {
                        if (impl.getPlayers()[i].isGoalKeeper()) {
                            c1 = uportero;
                        } else {
                            c1 = upantalon;
                        }
                    } else if (c0.equals(calcetas)) {
                        c1 = ucalcetas;
                    } else if (c0.equals(zapatos)) {
                        c1 = zapatos;
                    }
                    if (c1 != null) {
                        ib.setRGBA(x, y, c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha());
                    }
                }
            }
            imgJug[i][j] = ib.getImage();
        }
    }
}
项目:JavaRA    文件:TmpTexture.java   
private ImageBuffer applyPalette(int index) {
PalFile pal = ResourceManager.getInstance().getPaletteByName(
    type + ".pal");
Color[] colors = new Color[PALETTE_SIZE];

ByteBuffer bBuffer = pal.getPaletteDataByteBuffer();

// Use palette data
for (int i = 0; i < PALETTE_SIZE; i++) {
    int r = bBuffer.get() & BYTE_MASK;
    int g = bBuffer.get() & BYTE_MASK;
    int b = bBuffer.get() & BYTE_MASK;

    colors[i] = new Color(r, g, b);
}

bBuffer.rewind();

ByteBuffer bb = tmp.getImage(index);
// Allocate zeros filled buffer if image is empty
if (bb == null) {
    bb = ByteBuffer.allocate(width * height);
}

ImageBuffer imgbuf = new ImageBuffer(width, height);
for (int y = 0; y < width; y++) {
    for (int x = 0; x < height; x++) {
    int colorValue = bb.get() & BYTE_MASK;

    // Check for shadow color
    if (colorValue != SHADOW_COLOR) {
        imgbuf.setRGBA(x, y, colors[colorValue].getRed(),
            colors[colorValue].getGreen(), colors[colorValue]
                .getBlue(), (colorValue == 0) ? 0
                : NON_TRANSPARENT_ALPHA);
    } else {
        // Replace shadow color with black color with transparency
        imgbuf.setRGBA(x, y, 0, 0, 0, SHADOW_ALPHA_LEVEL);
    }
    }
}

bb.rewind();

return imgbuf;
   }
项目:JavaRA    文件:ShpTexture.java   
/**
    * Gets combined image by height of all .SHP frames
    * @param remapColor
    * @return
    */
   public Image getAsCombinedImage(Color remapColor, boolean isShadowSprite, int startFrame, int endFrame) {
int combinedHeight = this.height * this.numImages;
int combinedWidth = this.width;

Image img = RemappedTextureCache.getInstance().checkInCache(shp.getFileName(), remapColor, -1);
if (img != null) {
    return img;
}

// Image is not cached
// Create big sized common image, which will combine all frames of source .SHP
ImageBuffer imgBuf = new ImageBuffer(combinedWidth, combinedHeight);

if (endFrame == 0) {
    endFrame = this.numImages;
}

for (int i = startFrame; i < endFrame; i++) {
    ImageBuffer frameBuf = null;
    if (!isShadowSprite) { 
    frameBuf = remapShpFrame(i, remapColor); 
    } else {
    frameBuf = remapShpShadowFrame(i);
    }

    Image frame = frameBuf.getImage();

    byte[] rgba = frameBuf.getRGBA();

    int shiftX = 0;
    int shiftY = i * height;

    for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
        int r, g, b, a;
        Color c = frame.getColor(x, y);
        r = c.getRed();
        g = c.getGreen();
        b = c.getBlue();
        a = c.getAlpha();

        imgBuf.setRGBA(shiftX + x, shiftY + y, r, g, b, a);
    }
    }
}

// Cache result and return
img = imgBuf.getImage();
RemappedTextureCache.getInstance().putInCache(img, shp.getFileName(), remapColor, -1);
return img;
   }
项目:javacup    文件:PlayerRenderNew.java   
/**
 * Cambia los colores de una imagen
 */
public Image changeColor(Image img, float[] hueRatios, Color[] colors, boolean flip)
    throws SlickException {
  int width = img.getWidth();
  int height = img.getHeight();
  ImageBuffer imgBuf = new ImageBuffer(width, height);
  Color c;
  float[] v1 = new float[3];
  float[] v2 = new float[3];
  float brillo;
  for (int i = 0; i < width; i++) {
    for (int j = 0; j < height; j++) {
      for (int k = 0; k < colors.length; k = k + 2) {
        v1 =
            java.awt.Color.RGBtoHSB(colors[k].getRed(), colors[k].getGreen(), colors[k].getBlue(),
                                    v1);//HSB del color a cambiar
        c = img.getColor(i, j);
        v2 =
            java.awt.Color
                .RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), v2);//HSB del color del pixel
        brillo = v2[2] - v1[2];
        if ((c.getAlpha() > 0) && (Math.abs(v2[0] - v1[0]) < hueRatios[k / 2]
                                   || Math.abs(v1[0] + 1 - v2[0]) < hueRatios[k
                                                                              / 2])) {//optimizar... no repetir
          v1 =
              java.awt.Color.RGBtoHSB(colors[k + 1].getRed(), colors[k + 1].getGreen(),
                                      colors[k + 1].getBlue(),
                                      v1);//HSB del color al que se cambiara
          brillo = v1[2] + brillo;
          if (brillo < 0) {
            brillo = 0;
          }
          if (brillo > 1) {
            brillo = 1;
          }
          c = new Color(java.awt.Color.HSBtoRGB(v1[0], v1[1], brillo));
          k = colors.length;
        }
        if (flip) {
          imgBuf.setRGBA(width - i - 1, j, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
        } else {
          imgBuf.setRGBA(i, j, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
        }
      }
    }
  }
  return imgBuf.getImage();
}
项目:trashjam2017    文件:ImageBufferEndianTest.java   
/**
 * Fill a buffer with a given color
 *
 * @param buffer The buffer to fill
 * @param c The color to apply
 * @param width The width of the image
 * @param height The height of the image
 */
private void fillImageBufferWithColor(ImageBuffer buffer, Color c, int width, int height) {
   for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
         buffer.setRGBA(x, y, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
      }
   }
}
项目:Progetto-C    文件:ImageBufferEndianTest.java   
/**
 * Fill a buffer with a given color
 *
 * @param buffer The buffer to fill
 * @param c The color to apply
 * @param width The width of the image
 * @param height The height of the image
 */
private void fillImageBufferWithColor(ImageBuffer buffer, Color c, int width, int height) {
   for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
         buffer.setRGBA(x, y, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
      }
   }
}
项目:BaseClient    文件:ImageBufferEndianTest.java   
/**
 * Fill a buffer with a given color
 *
 * @param buffer The buffer to fill
 * @param c The color to apply
 * @param width The width of the image
 * @param height The height of the image
 */
private void fillImageBufferWithColor(ImageBuffer buffer, Color c, int width, int height) {
   for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
         buffer.setRGBA(x, y, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
      }
   }
}
项目:GPVM    文件:ImageBufferEndianTest.java   
/**
 * Fill a buffer with a given color
 *
 * @param buffer The buffer to fill
 * @param c The color to apply
 * @param width The width of the image
 * @param height The height of the image
 */
private void fillImageBufferWithColor(ImageBuffer buffer, Color c, int width, int height) {
   for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
         buffer.setRGBA(x, y, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
      }
   }
}
项目:SpaceStationAlpha    文件:ImageBufferEndianTest.java   
/**
 * Fill a buffer with a given color
 *
 * @param buffer The buffer to fill
 * @param c The color to apply
 * @param width The width of the image
 * @param height The height of the image
 */
private void fillImageBufferWithColor(ImageBuffer buffer, Color c, int width, int height) {
   for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
         buffer.setRGBA(x, y, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
      }
   }
}
项目:cretion    文件:ImageBufferEndianTest.java   
/**
 * Fill a buffer with a given color
 *
 * @param buffer The buffer to fill
 * @param c The color to apply
 * @param width The width of the image
 * @param height The height of the image
 */
private void fillImageBufferWithColor(ImageBuffer buffer, Color c, int width, int height) {
   for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
         buffer.setRGBA(x, y, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
      }
   }
}
项目:slick2d-maven    文件:ImageBufferEndianTest.java   
/**
 * Fill a buffer with a given color
 *
 * @param buffer The buffer to fill
 * @param c The color to apply
 * @param width The width of the image
 * @param height The height of the image
 */
private void fillImageBufferWithColor(ImageBuffer buffer, Color c, int width, int height) {
   for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
         buffer.setRGBA(x, y, c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
      }
   }
}