delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/14/12:40:25

From: "Michael Stewart" <mike AT reggin DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Flipping an image
Date: Wed, 14 Jul 1999 09:15:11 +0100
Organization: (Posted via) Netcom Internet Ltd.
Lines: 26
Message-ID: <7mhguh$apb$1@taliesin.netcom.net.uk>
References: <7mf2qk$nlg$1 AT rockall DOT cc DOT strath DOT ac DOT uk> <7mfdr3$m9r$1 AT taliesin DOT netcom DOT net DOT uk> <Pine DOT SUN DOT 3 DOT 96 DOT 990713113215 DOT 6737A-100000 AT silver DOT cs DOT umanitoba DOT ca>
NNTP-Posting-Host: hgty.capgemini.co.uk
X-Trace: taliesin.netcom.net.uk 931940113 11051 194.42.240.2 (14 Jul 1999 08:15:13 GMT)
X-Complaints-To: abuse AT corp DOT netcom DOT net DOT uk
NNTP-Posting-Date: 14 Jul 1999 08:15:13 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3155.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Mark Phillips wrote in message ...
>> Alan Wills wrote in message <7mf2qk$nlg$1 AT rockall DOT cc DOT strath DOT ac DOT uk>...
void flip_image(int array[], int rows, int cols) {

   int row_count, col_count, total_pixelsp, tmp;

   for (row_count = 0; row_count < rows; row_count++) {
      for(col_count = 0; col_count < cols / 2; col_count++) {
      // Something like this ? (note: this is untested)
      tmp = array[row_count * cols + col_count];
      array[row_count * cols + col_count] = array[(row_count + 1) * cols -
1 - col_count];
      array[(row_count + 1) * cols - 1 - col_count] = tmp;
      }
   }
}
>
>I'm pretty sure if you do it this way you'll only want the inside loop to
>go up to cols/2 instead of cols since then you'd be flipping the image and
>then re-flipping it back the way it was.


Doh! The above code has been changed to use cols/2. Sorry about that.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019