Image loading part 1
This commit is contained in:
parent
8e7367dce8
commit
ca8dfb9735
3 changed files with 67 additions and 0 deletions
Binary file not shown.
|
@ -2,6 +2,8 @@ package bz.bronze.pixels.engine;
|
|||
|
||||
import java.awt.image.DataBufferInt;
|
||||
|
||||
import bz.bronze.pixels.engine.gfx.Image;
|
||||
|
||||
public class Renderer {
|
||||
private int pW, pH;
|
||||
private int[] p;
|
||||
|
@ -23,4 +25,18 @@ public class Renderer {
|
|||
p[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPixel(int x, int y, int value) {
|
||||
if ((x < 0 || x >= pW || y < 0 || y >= pH) || value == 0xffff00ff) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void drawImage(Image image, int offX, int offY) {
|
||||
for (int y = 0; y < image.getH(); y++) {
|
||||
for (int x = 0; x < image.getW(); x++) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
51
pixels/src/bz/bronze/pixels/engine/gfx/Image.java
Normal file
51
pixels/src/bz/bronze/pixels/engine/gfx/Image.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package bz.bronze.pixels.engine.gfx;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class Image {
|
||||
private int w, h;
|
||||
private int[] p;
|
||||
|
||||
public Image(String path) {
|
||||
BufferedImage image = null;
|
||||
|
||||
try {
|
||||
image = ImageIO.read(Image.class.getResourceAsStream(path));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
w = image.getWidth();
|
||||
h = image.getHeight();
|
||||
p = image.getRGB(0, 0, w, h, null, 0, w);
|
||||
|
||||
image.flush();
|
||||
}
|
||||
|
||||
public int getW() {
|
||||
return w;
|
||||
}
|
||||
|
||||
public int getH() {
|
||||
return h;
|
||||
}
|
||||
|
||||
public int[] getP() {
|
||||
return p;
|
||||
}
|
||||
|
||||
public void setW(int w) {
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public void setH(int h) {
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
public void setP(int[] p) {
|
||||
this.p = p;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue