NearlyDefault

Less Edgy Default Textures

 

Downloads under "Files"

Source Code

public void scaleup(File infile, File opath) throws IOException {
		BufferedImage image=ImageIO.read(infile);
		if(image==null){return;}
		opath.getParentFile().mkdirs();
		int scal=((Math.min(image.getWidth(), image.getHeight())>=24)?2:4);
		BufferedImage scaled=new BufferedImage(image.getWidth()*scal,image.getHeight()*scal,image.getType());
		for(int x=0;x<scaled.getWidth();x++){
			for(int y=0;y<scaled.getHeight();y++){
				scaled.setRGB(x, y, image.getRGB(x/scal, y/scal));
			}
		}
		int[] pixel=new int[9];
		int[] R=new int[9];
		int[] G=new int[9];
		int[] B=new int[9];
		int[] A=new int[9];
		for(int i=1;i<scaled.getWidth()-1;i++){
			for(int j=1;j<scaled.getHeight()-1;j++){
				int ma=(scaled.getRGB(i, j) >> 24) & 0xff;
				pixel[0]=scaled.getRGB(i-1,j-1);
				pixel[1]=scaled.getRGB(i-1,j);
				pixel[2]=scaled.getRGB(i-1,j+1);
				pixel[3]=scaled.getRGB(i,j+1);
				pixel[4]=scaled.getRGB(i+1,j+1);
				pixel[5]=scaled.getRGB(i+1,j);
				pixel[6]=scaled.getRGB(i+1,j-1);
				pixel[7]=scaled.getRGB(i,j-1);
				pixel[8]=scaled.getRGB(i,j);
				for(int k=0;k<9;k++){
					R[k]=(pixel[k] >> 16) & 0xFF;
					G[k]=(pixel[k] >> 8) & 0xFF;
					B[k]=(pixel[k] >> 0) & 0xFF;
					A[k]=(pixel[k] >> 24) & 0xff;
				}
				Arrays.sort(R);
				Arrays.sort(G);
				Arrays.sort(B);
				Arrays.sort(A);
				scaled.setRGB(i,j, (((Math.min(ma,A[4]) & 0xFF) << 24) |
						((R[4] & 0xFF) << 16) |
						((G[4] & 0xFF) << 8)  |
						((B[4] & 0xFF) << 0)));
			}
		}
		ImageIO.write(scaled, "png", opath);
	}

 

 


Comments

Posts Quoted:
Reply
Clear All Quotes

About This Project

  • Project ID
    253209
  • Created
    Nov 4, 2016
  • Last Released File
    May 5, 2018
  • Total Downloads
    10,004
  • License

Categories

Members