Search in sources :

Example 21 with BufferedImage

use of java.awt.image.BufferedImage in project android_frameworks_base by ParanoidAndroid.

the class RenderDrawable method getImage.

protected BufferedImage getImage(int w, int h) {
    BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D gc = image.createGraphics();
    gc.setComposite(AlphaComposite.Src);
    gc.setColor(new Color(0x00000000, true));
    gc.fillRect(0, 0, w, h);
    // done
    gc.dispose();
    return image;
}
Also used : Color(java.awt.Color) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 22 with BufferedImage

use of java.awt.image.BufferedImage in project BluePower by Qmunity.

the class GateComponentLever method onLayoutRefresh.

@Override
public void onLayoutRefresh() {
    if (layoutColor == -1)
        return;
    BufferedImage img = getGate().getLayout().getLayout(layoutColor);
    x = img.getWidth();
    z = img.getHeight();
    for (int x = 0; x < img.getWidth(); x++) {
        for (int y = 0; y < img.getWidth(); y++) {
            if ((img.getRGB(x, y) & 0xFFFFFF) != 0) {
                this.x = Math.min(this.x, x);
                z = Math.min(z, y);
            }
        }
    }
    x = x / (img.getWidth());
    z = z / (img.getHeight());
}
Also used : BufferedImage(java.awt.image.BufferedImage)

Example 23 with BufferedImage

use of java.awt.image.BufferedImage in project BluePower by Qmunity.

the class GateComponentSolarPanel method onLayoutRefresh.

@Override
public void onLayoutRefresh() {
    if (layoutColor == -1)
        return;
    BufferedImage img = getGate().getLayout().getLayout(layoutColor);
    x = img.getWidth();
    z = img.getHeight();
    for (int x = 0; x < img.getWidth(); x++) {
        for (int y = 0; y < img.getWidth(); y++) {
            if ((img.getRGB(x, y) & 0xFFFFFF) != 0) {
                this.x = Math.min(this.x, x);
                z = Math.min(z, y);
            }
        }
    }
    x = x / (img.getWidth());
    z = z / (img.getHeight());
}
Also used : BufferedImage(java.awt.image.BufferedImage)

Example 24 with BufferedImage

use of java.awt.image.BufferedImage in project BluePower by Qmunity.

the class GateComponentButton method onLayoutRefresh.

@Override
public void onLayoutRefresh() {
    if (layoutColor == -1)
        return;
    BufferedImage img = getGate().getLayout().getLayout(layoutColor);
    x = img.getWidth();
    z = img.getHeight();
    for (int x = 0; x < img.getWidth(); x++) {
        for (int y = 0; y < img.getWidth(); y++) {
            if ((img.getRGB(x, y) & 0xFFFFFF) != 0) {
                this.x = Math.min(this.x, x);
                z = Math.min(z, y);
            }
        }
    }
    x = x / (img.getWidth());
    z = z / (img.getHeight());
}
Also used : BufferedImage(java.awt.image.BufferedImage)

Example 25 with BufferedImage

use of java.awt.image.BufferedImage in project LogisticsPipes by RS485.

the class RequestMonitorPopup method saveTreeToImage.

private void saveTreeToImage() {
    int useWidth = mc.displayWidth;
    int useHeight = mc.displayHeight;
    int left = minX - (width / 2);
    int top = minY;
    int right = maxX - (width / 2);
    int bottom = maxY;
    int k = useWidth * useHeight;
    IntBuffer pixels = BufferUtils.createIntBuffer(k);
    int[] intArray = new int[k];
    int imgPosX = 0;
    int imgPosY = 0;
    for (int x = left; x < right + width; x += width) {
        imgPosY = 0;
        for (int y = top; y < bottom + height; y += height) {
            imgPosY += useHeight;
        }
        imgPosX += useWidth;
    }
    BufferedImage bufferedimage = new BufferedImage(imgPosX, imgPosY, 1);
    imgPosX = 0;
    imgPosY = 0;
    //Clear everything
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glLoadIdentity();
    mc.entityRenderer.setupOverlayRendering();
    drawForSreenShot(0, 0);
    //Start Creating the Image
    for (int x = left; x < right + width; x += width) {
        imgPosY = 0;
        for (int y = top; y < bottom + height; y += height) {
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
            mc.entityRenderer.setupOverlayRendering();
            drawForSreenShot(y, x);
            pixels.clear();
            GL11.glReadPixels(0, 0, useWidth, useHeight, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
            pixels.get(intArray);
            RequestMonitorPopup.mirror(intArray, useWidth, useHeight);
            bufferedimage.setRGB(imgPosX, imgPosY, Math.min(useWidth, bufferedimage.getWidth() - imgPosX), Math.min(useHeight, bufferedimage.getHeight() - imgPosY), intArray, 0, useWidth);
            imgPosY += useHeight;
        }
        imgPosX += useWidth;
    }
    saveImage(bufferedimage);
}
Also used : IntBuffer(java.nio.IntBuffer) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BufferedImage (java.awt.image.BufferedImage)1364 Graphics2D (java.awt.Graphics2D)335 IOException (java.io.IOException)186 File (java.io.File)164 Graphics (java.awt.Graphics)91 ByteArrayInputStream (java.io.ByteArrayInputStream)80 Color (java.awt.Color)74 ByteArrayOutputStream (java.io.ByteArrayOutputStream)74 Test (org.junit.Test)72 WritableRaster (java.awt.image.WritableRaster)65 Rectangle (java.awt.Rectangle)60 AffineTransform (java.awt.geom.AffineTransform)52 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)46 InputStream (java.io.InputStream)46 Image (java.awt.Image)43 Dimension (java.awt.Dimension)42 ImageWriter (javax.imageio.ImageWriter)40 Point (java.awt.Point)36 ArrayList (java.util.ArrayList)36 ImageIcon (javax.swing.ImageIcon)35