some help needed

This is a discussion on some help needed within the C Programming forums, part of the General Programming Boards category; Hi, This is a small section of my code which is developed to get an image and store it in ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    54

    some help needed

    Hi, This is a small section of my code which is developed to get an image and store it in an array blah blah and flip the image horizontally and vertically (which works perfectly), however the program also needs to scroll the image horizontally and vertically which i dont know how to do,... can some one please let me know how to do that or at least point me towards the right direction?
    (This program has a library code and a mainline code which calls the procedures and functions)

    ta

    Code:
    //image flip vertically procedure
    void image_process_flip_vertically(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y],int height,int width)
    {
    int row;                        // row count variable
    int column;                     // column count variable
    int temp_row;                   // inverse of row to flip image
    int temp_array[height][width];  // temp array to store scrolled image
    
            // flipping process
            for (column = 0;column < width; column++)       // column count loop
            {
                    for (row = 0; row < height; row++)      // row count loop
                    {
                    temp_row =  height - 1 - row;           // set temp row
                    temp_array [row][column] = image_data [temp_row][column];// place pixel into temp array in its new spot
                    }//endfor
            }//endfor
    
            // Returning temp array to image_data
            for (column = 0; column < width; column++)      // column count loop
            {
                    for (row = 0; row < height; row++)      // row count loop
                    {
                            image_data [row][column] = temp_array [row][column]; //returning flippeded image to image_data
                    }//endfor
            }//endfor
    }//endprocedure
    
    //image flip horizontally procedure
    void image_process_flip_horizontally(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y],int height,int width)
    {
    int row;                // row count variable
    int column;             // column count variable
    int temp_column;        // inverse of cloumn to flip image
    int temp_array[height][width]; //temp array to store scrolled image
    
            // flipping process
            for (row = 0; row < height; row++)      // row count loop
            {
                    for (column = 0; column < width; column++) // column count loop
                    {
                            temp_column = width - 1 - column;       // set temp column
                            temp_array[row][column] = image_data[row][temp_column];// place pixel into temp arayy in its new spot
                    }//endfor
            }//endfor
    
            // Returning temp array to image_data
            for (row = 0; row < height; row++)      // row count loop
            {
                    for(column = 0; column < width; column++)       // column count loop
                    {
                            image_data[row][column]=temp_array[row][column]; //returning flipped image to image_data
                    }//endfor
            }//endfor
    }//endprocedure
    Last edited by juststartedC; 10-22-2007 at 11:11 AM.

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    scroll the image horizontally and vertically which i dont know how to do
    What does that mean? Move all the pixels right so many spots? (And shift the ones that move off the image back to the other side?) Something like:
    Code:
    temp_image[row][(column + shift) &#37; width] = image[row][column]
    Also, your flipping functions are confused. Is your image data row major or column major? You access pixel data with:
    Code:
    image[row][column]
    Which seems to say: image[y][x]. But your function declaration:
    Code:
    void image_process_flip_horizontally(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y],int height,int width)
    Says image[x][y] ... which is it?

    Edit: Also, image flipping shouldn't require a temporary copy... just flip the pixel with the corresponding pixel on the image, and only iterate through the first half.
    Last edited by Cactus_Hugger; 10-22-2007 at 11:47 AM.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    54
    Thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 10:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 12:55 PM
  3. lock needed in this scenario?
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-25-2008, 08:22 AM
  4. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-01-2004, 12:24 AM
  5. semi-colon - where is it needed
    By kes103 in forum C++ Programming
    Replies: 8
    Last Post: 09-12-2003, 06:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21