package com.dazkins.CityTycoon.gfx; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.util.Arrays; import java.util.Random; public class Bitmap implements Cloneable{ public int w,h; public int[] pixels; public Bitmap(Bitmap b){ this.w=b.w; this.h=b.h; this.pixels=b.pixels; } public Bitmap(BufferedImage img){ if(img!=null){ this.w=img.getWidth(); this.h=img.getHeight(); pixels=((DataBufferInt)img.getRaster().getDataBuffer()).getData(); } } public Bitmap(int w, int h, int[] pixels){ this.w=w; this.h=h; this.pixels=pixels; } public Bitmap(int w,int h,int color){ this.w=w; this.h=h; this.pixels = new int[w*h]; for(int i = 0; i < w * h; i++){ this.pixels[i] = color; } } public Bitmap(int width, int height) { this.w=width; this.h=height; this.pixels = new int[w*h]; } public void randomize(){ for(int i=0;i this.w) x1 = this.w; if(y0 < 0) y0 = 0; if(y1 > this.h) y1 = this.h; for(int x = x0; x < x1; x++){ for(int y = y0; y < y1; y++){ int pixelPos = (x-xp) + ((y-yp)*b.w); if(xFlip && !yFlip){ pixelPos = (b.w-(x-xp+1)) + (((y-yp))*b.w); }else if(yFlip && !xFlip){ pixelPos = ((x-xp)) + ((b.h-(y-yp+1))*b.w); }else if(yFlip && xFlip){ pixelPos = (b.w-(x-xp+1)) + ((b.h-(y-yp+1))*b.w); } if(b.pixels[pixelPos] != 0xFFFF00FF){ this.pixels[x+y*w] = b.pixels[pixelPos]; } } } } public void renderWithModifiedColour(Bitmap b,int xp,int yp,boolean xFlip,boolean yFlip,int col){ Bitmap b0 = new Bitmap(b.w,b.h); for(int i=0;i