0

Ok well i have a function called drawVerticalLine and it's method header is the following : void drawVerticalLine(int[][] img,int lineWidth, int linePosition)

so what happenes is a picture is converted to a 2d array etc and passed on to this function, now the goal is to draw a red verticle line on the picture.

also i have a declared variable called : final static int RED = Color.RED.getRGB();

to set the color of the vertical line

Now so far i've figured this out :

  public static void drawVerticalLine(int[][] img,int lineWidth, int linePosition)
  {
     for(int i=0;i = linePosition;i++)
     {
         for(int j=0; j=lineWidth; j++)
         {
        // have no idea what to do  
         }
     } 
  }

Now i dont have any experience with images, i do more calculating stuff, however i've been asked to try to accomplish this task. some help would be really appreciated.

Thank You.

Edited by Reverend Jim: Fixed formatting

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by tong1
0

To drawing a line one has to use the instance of Graphics : Graphics g so that the method in drawing a line can be applied:
g.drawLine(int x1, int y1, int x2, int y2) ;
which draws a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate .

Hence the method drawVerticalLine you posted should have a parameter of the type of Graphics (or use other way to obtain the instance of Graphics).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.