|
|
|
@ -13,7 +13,7 @@ public enum Sprite{ |
|
|
|
|
NANA(new File(new File("..","sprites"),"3x.png")), |
|
|
|
|
NANA_SMALL(new File(new File("..","sprites"),"1x.gif")), |
|
|
|
|
TILE_SHEET(new File(new File("..","sprites"),"tiles.gif")), |
|
|
|
|
MAP_TILE_INFO(new File(new File("..","sprites"),"maptileinfo.gif")), |
|
|
|
|
MAP_TILE_INFO(new File(new File("..","sprites"),"maptileinfo-1.png.png")), |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,7 +28,42 @@ public enum Sprite{ |
|
|
|
|
BufferedImage img = ImageIO.read(filename); |
|
|
|
|
this.width=img.getWidth(); |
|
|
|
|
this.height=img.getHeight(); |
|
|
|
|
bi_array = ((DataBufferByte)(img.getRaster().getDataBuffer())).getData(); |
|
|
|
|
|
|
|
|
|
if (filename.getName().endsWith(".png")) { |
|
|
|
|
System.out.println(" WARNING! PNGs are not officially supported! Will attempt to convert anyways."); |
|
|
|
|
bi_array=new byte[width*height]; |
|
|
|
|
for (int y=0;y<height;y++) { |
|
|
|
|
for (int x=0;x<width;x++) { |
|
|
|
|
int col = img.getRGB(x, y); |
|
|
|
|
int r = (col&0xff0000)>>>16; |
|
|
|
|
int g = (col&0xff00)>>>8; |
|
|
|
|
int b = col&0xff; |
|
|
|
|
boolean found=false; |
|
|
|
|
for (int c=0;c<Panel.generalPalette.length;c+=3) { |
|
|
|
|
if (Panel.generalPalette[c]==(byte)r&& |
|
|
|
|
Panel.generalPalette[c+1]==(byte)g&& |
|
|
|
|
Panel.generalPalette[c+2]==(byte)b) { |
|
|
|
|
System.out.println(" Matched color index["+((byte)(c/3))+"]"); |
|
|
|
|
bi_array[y*width+x]=(byte)(c/3); |
|
|
|
|
found=true; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if ((byte)0xff==(byte)r&&(byte)0x0==(byte)g&&(byte)0xff==(byte)b) { |
|
|
|
|
System.out.println(" Matched color index[32]"); |
|
|
|
|
bi_array[y*width+x]=32; |
|
|
|
|
found=true; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!found) { |
|
|
|
|
System.out.println(" COLOR NOT FOUND! USING TRANSPARENCY BY DEFAULT. ("+r+","+g+","+b+")"); |
|
|
|
|
bi_array[y*width+x]=32; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
bi_array = ((DataBufferByte)(img.getRaster().getDataBuffer())).getData(); |
|
|
|
|
} |
|
|
|
|
if (this.ordinal()==3) { |
|
|
|
|
System.out.println(Arrays.toString(bi_array)); |
|
|
|
|
} |
|
|
|
|