png - generating design with java -


enter image description here

i trying generate following given sateen design of java code code not creating png file named sateen

import java.awt.*; import java.awt.image.bufferedimage;  import java.io.*;  import javax.imageio.imageio; import javax.swing.jframe;   public class sateen {  bufferedimage  image; int width; int height; int red,green,blue;   public sateen() {    try {      file input = new file("n.png");      image = imageio.read(input);      width = image.getwidth();      height = image.getheight();      //n png file white pixels      for(int i=0; i<height; i++){          for(int j=0; j<width; j++){             color p = new color(image.getrgb(j, i));          color g = new color(image.getrgb(j+5, i));                     //getting (j,i) coordinate pixel value , comparing       next 5th pixel    if(p.getred()==255&&p.getblue()==255&&p.getgreen()==255&&g.getred()==255&&     g.getblue()==255&&g.getgreen()==255)                    {                                  red=0;                                       blue=0;                              green=0; }            //if both pixel value white setting 5th pixel value black            color newcolor = new color(red,green,blue);              image.setrgb(j+5,i,newcolor.getrgb());        j=j+5;          }      }       file ouptut = new file("sateen.png");      imageio.write(image, "png", ouptut);      //creating sateen png file      } catch (exception e) {}    }  static public void main(string args[]) throws exception    {   sateen obj = new sateen();  } } 

seems create .png file (make sure filepath correct?). code not generate sateen pattern, rather draws black pixels @ column 6, 12, 18 etc.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -