Thread: rotating a text file

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    13

    Unhappy rotating a text file

    I am creating a program where I have to rotate an image 90', 180' and 270'. The file being read in is an image file converted to numbers and these are read into an array.
    The image is 60 ROWS by 60 COLS, the array being Picture2

    To rotate the image 90' i am doing the following;

    for (i=0; i<ROWS; i++)
    for (j=0; j<COLS; j++)
    Picture2[COLS-1-j][i]=Picture[i][j];


    and to rotate the image 270' i am doing the following;

    for (i=0; i<ROWS; i++)
    for (j=0; j<COLS; j++)
    Picture2[j][ROWS-1-i]=Picture[i][j];


    The recent suggestion to calling the rotate 90' function twice doesn't work so I still have no idea how to rotate it by 180' without doing the obvious of printing it out and turning the bit paper upside down!

    Thanks for any help, it is EXTREMELY appreciated and if you need to look at the program then please email me and I will be happy to send you it ok!

  2. #2
    Unregistered
    Guest
    Did you try :

    Picture2 [ROWS-1-i][COLS-1-j]=Picture[i][j]; ?

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    22
    Then i wanna aask how to display an image in C ?.......
    ______________________
    Wut ?

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    for learning to display an image in C....


    READ THE FAQ!!

    just a bit of advice that'll get you far.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    > The recent suggestion to calling the rotate 90' function twice doesn't work
    But it makes sense that it ought to work right?

    Did you call it like this?
    rotate90( picture, temp );
    rotate90( temp, picture2 );

    Or like this
    rotate90( picture, picture2 );
    rotate90( picture2, picture2 );

    Because if it's the latter, then I'm not surprised it didn't work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM